Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note that it is assumed the latest version 2.0.0 of UIP Visual Studio Code Extension (or and uip-cliis cli are already installed. See the previous document for installation instructions.

Step 1 - Create a New Extension Project using the UIP VS Code Extension

As mentioned in Development Environment Set-Up, this tutorial will be using Visual Studio Code running in Windows and connected to a WSL (Windows Subsystem for Linux) project environment.

...

In the resulting dialog, navigate to the sample-task folder and click on Select Folder:

Selecting starter template

Now that VS Code is in the WSL environment, open the command pallet (ctrl+shift+p) and type "UIP".  This will show all the UIP Extension commands:

Image Removed

The command we are interested in now is UIP: Initialize New Project.  Note that the commands can show up in varying orders depending on use.  If the UIP: Initialize New Project is not visible, type "uip init" to further filter the displayed commands.

Image Removed

Select the UIP: Initialize New Project command.

If you have not yet installed uip-cli on the WSL system, you will likely be presented with two notifications after selecting UIP: Initialize New Project:

Image Removed

  1. Indicates that uip-cli has not been installed to the selected Python environment and gives options for installing it.  This notification comes from the UIP extension.
  2. Indicates that a Python interpreter has not been selected. This notification comes from the Python extension

The first notification (1), indicates that uip-cli is not installed in this Python environment and gives some options for installation.  Note that there is currently no Python interpreter for the project so, the system python ("python") is used as the default.  If the indicated Python environment is agreeable, choose one of the install options.  

Info

The installation of uip-cli is performed by calling pip install. Selecting “Yes (user)” from the notification will cause pip to perform a user scheme install where uip-cli is installed to the Python user install directory for the platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full details.).

Info
If the default Python is not acceptable or desirable for uip-cli installation, select "No".  This will cancel the UIP: Initialize New Project operation and allow you to select a specific Python environment (from notification 2).  Once an acceptable Python environment has been selected, open the command pallet again and select UIP: Initialize New Project.
Info
Once uip-cli has been installed to a Python environment, the notifications will no longer pop-up for UIP operations using that Python environment.

After an install option is selected, uip-cli will be installed to the target Python environment.  The results of the installation procedure can be seen in a UIP terminal window that opens within VS Code.  Additionally, the "Select UIP Project Folder" dialog will be displayed at the top of the VS Code window:

Image Removed

  1. UIP terminal with output from uip-cli install.
  2. The "Select UIP Project Folder" dialog.

At this point, the sample-task folder should be selected in the dialog so, go ahead and click "OK". 

Note that, this dialog can be used to navigate to another folder.  This is useful if you start the UIP: Initialize New Project process when VS Code is opened on a folder other than the target of initialization.

Selecting a starter template

After selecting "OK", the UIP project initialization process starts on the selected folder and you are presented with a list of available "starter templates" for the UIP project.  Starter templates contain boiler plate code to kick-start a project.  At the time of this writing, two starter templates are available: ue-task and ue-publisher.  For now, we will be working with ue-task (ue-publisher will be demoed later in the tutorial series), so go ahead and click on the ue-task template.

Image Removed

navigate to the activity bar on the left hand size and click the Stonebranch logo.

Image Added

This will expand the menu and you should see a list of all the available extension templates. Go ahead and click the icon shown below to initialize the ue-task template:

Image Added

Setting template parameter values for selected starter template

Starter templates contain parameters that A few seconds after clicking the icon shown above, a sequence of input boxes will shown up containing the parameters for the ue-task starter template. The parameters allow you to supply project specific values into boilerplate template code at creation time.

Once the starter template is selected, the available parameters are presented one by one with default values pre-selected. For this tutorial, all parameters are suitable so, just pressing 'Enter' to select the default for each parameter would be sufficient.  However, in the series of images below, the 'Extension Owner' parameter was modified to use a value of "SampleOwner" (step 6/8).  Notice that the dialog title will update to indicate which step you are on and how many steps are left to complete the dialog - (2/8), (3/8), (4/8), etc..  

...

  • Open the command pallet (ctrl+shift+p) and type "uip build" and select UIP: Build All:

    The UIP: Build All command will build the full package (Extension + Universal Template). Recall that the Universal Template is called UE Task, and it does not exist in the Controller. Therefore, the entire package must be built and uploaded.
    When the command is selected, a UIP terminal window will be opened in VS Code and the uip-cli command 'uip build -a' will be executed.  The results of the command can be reviewed in the terminal:
    Image Removed
    Verify Upon selecting the command, the status bar will show the build command running in the background:
    Image Added

  • If the command succeeded, you should see the full package was built by going to the ./sample-task/dist/package_build folder, and making sure UE_Task_universal_template.zip file exists:


  • Upload the full package using the UIP: Upload All command:

    Once again, the UIP: Upload All option indicates the full package needs to be uploaded.

    When the command is selected, a UIP terminal window will be opened (if not already open) and the uip-cli command 'uip upload -a' will be executed.  The results of the command can be reviewed in the terminal:
    Image Removed
    the plugin will upload the full package, in the background. If an error occurs, you will get a notification.

  • Verify the UE Task Universal Template and ue-task Extension are created on the Controller side:





    1) Click the "Refresh" icon, if necessary
    2) Verify the UE Task template is listed
    3) Verify the template name is UE Task
    4) Verify the ue-task Extension is attached to the template

  • Verify the UE Task template contains the "action" field:
    • If you are curious, double-click the "action" field and explore the field details. In the "Choices" tab, you will see the 'print' and 'log' choices      

...

  • Open the command pallete and run the UIP: Push command:

    When the command is selected, a UIP terminal window will be opened (if not already open) and the uip-cli command 'uip push
    ' will be executed.  The results of the command can be reviewed in the terminal:
    Image RemovedThe command will continue to run, in background. You should see the status bar updated as follows:
    Image Added

    If the command failed, you should get an error notification. You can view the command output anytime in the UIP output channel

    Image Added

    Instead of UIP: Build All followed by UIP: Upload All, this time UIP: Push was used as it is essentially just a combination of UIP: Build and UIP: Upload. Notice that the UIP: Push All command was not used given that we are only pushing the Extension and not the entire package. If the template.json file was modified locally, then the UIP: Push All command should be used to update the entire package on the Controller side. 
    If you are wondering how the UIP: Push command knows what Universal Template to push the ue-task extension to, open the ~/dev/extensions/sample-task/src/templates/template.json file, and there will be a field called "name" with the value "UE Task". The "UE Task" is the name of the Universal Template. Internally, the CLI reads the template.json file and extracts the name from it. 

...

Code Block
languagepy
titleextension.py
linenumberstrue
from __future__ import (print_function)
from universal_extension import UniversalExtension
from universal_extension import ExtensionResult
from universal_extension import logger


class Extension(UniversalExtension):
    """Required class that serves as the entry point for the extension
    """

    def __init__(self):
        """Initializes an instance of the 'Extension' class
        """
        # Call the base class initializer
        super(Extension, self).__init__()

    def extension_start(self, fields):
        """Required method that serves as the starting point for work performed
        for a task instance.

        Parameters
        ----------
        fields : dict
            populated with field values from the associated task instance
            launched in the Controller

        Returns
        -------
        ExtensionResult
            once the work is done, an instance of ExtensionResult must be
            returned. See the documentation for a full list of parameters that
            can be passed to the ExtensionResult class constructor
        """

        # Get the value of the 'action' field
        action = fields.get('action', [""])[0]

        if action.lower() == 'print':
            # Print to standard output...
            print("Hello STDOUT!")
        else:
            # Log to standard error...
            logger.info('Hello STDERR!')

        # Return the result with a payload containing a Hello message...
        return ExtensionResult(
            unv_output='Hello Extension!'
        )

< Previous     Next >