How-To Guides
Applications Guides

Use Marketplace SDK with Python

11min
in this example, the marketplace application consumes data from a topic, does some analysis, and pushes the data to a new topic for this example, a docker image is built, the image is transferred to an edge device using ftp, access is provided to a topic, the container is run from the docker image, and the application is tested using flows download the set of files below as a reference https //archbee doc uploads s3 amazonaws com/ssuuxkzuk9bftepnn 6zo/m4gx6eoutle0nmudbhqj3 marketplace sdk python zip before you begin make sure you have access to the following a linux system and docker engine python so that you can access the files in the marketplace sdk python zip file step 1 build the docker image the main py file in the marketplace sdk python files consists of the logic that must be written to manipulate the data the code is well commented and can be used as a reference you can also make changes in the container from the manufacturing connect edge terminal from a linux computer, execute the following command docker build t python sdk step 2 transfer the image to an edge device to transfer the image to an edge device in manufacturing connect edge, navigate to system > services the services pane appears from the ftp service section, click start the ftp service is started click add user the add user dialog box appears enter a user name and click add user the create user dialog box appears click the copy icon next to the password, save it somewhere safe, and then click close the user is added to the ftp users list from the linux system, use an ftp client such as file zilla to connect to the ftp server on port 21 navigate to the docker images folder in ftp data/docker images and add the tar file (docker saved image tar) that is the locally saved version of your container return to the services browser tab and navigate to applications > images the images pane appears from the images pane, click the add icon the import image dialog box appears select the ftp option click the image file path field and select the tar file from the drop down list click import the image is uploaded to the images list step 3 run the container to run the container in manufacturing connect edge, navigate to applications > images > containers the containers pane appears click the start icon next to the image name the selected application runs step 4 create an api account to create an api account in manufacturing connect edge, navigate to system > tokens from the access accounts section, click the add icon the create api account dialog box appears enter the account name and click create account the new account appears in the access accounts section on the tokens pane step 5 create topics to create topics in manufacturing connect edge, navigate to system > tokens from the access accounts section, click the action menu next to a selected account and select edit topics the account form drops down perform one or both of the following from the read topics section, enter a name in the topic name field, and then click add read topic these are the subscribe topics you will use later from the write topics section, enter a name in the topic name field, and then click add write topic these are the publish topics you use later repeat as needed when you are done adding topics, click update click ok step 6 copy the api key to copy the api key in manufacturing connect edge, navigate to system > tokens from the access accounts section, click the action menu next to a selected account and select view api key click the copy icon next to the api key the api key is copied to your clipboard click close step 7 run the application when you run the application, refer to the following command for step 3 docker run d python sdk \ mode=\<product> access \ api key=\<api key> \ \<product> access address=10 30 50 1 9094 \ inbound topic=\<subscribe topic> \ outbound topic=\<publish topic to run the application in manufacturing connect edge, navigate to applications > containers click run copy and paste the command above in the command line for the above docker entry replace \<product> with your product name replace \<api key> with your api key replace \<subscribe topic> with the topic you want to subscribe to replace \<publish topic> with the topic you want to publish click run step 8 validate the application to validate the application in manufacturing connect edge, navigate to flows manager click the go to flow definition icon for a selected flows manager the flow canvas opens in a new browser tab drag the inject node and the datahub publish node to the canvas and wire them together double click the inject node the edit inject node dialog box appears from the repeat drop down list, select interval in the name field, enter timestamp message generator click done double click the datahub publish node the edit datahub publish node dialog box appears from the edit datahub publish node dialog box, configure the following datahub make sure add new datahub connect is selected topic enter the subscribe topic name you created earlier name enter connector click done drag the datahub subscribe node and the debug node to the canvas and wire them together double click the datahub subscribe node the edit datahub subscribe node dialog box appears from the edit datahub publish node dialog box, configure the following datahub make sure add new datahub connect is selected topic enter the publish topic name you created earlier name enter listener click done click deploy drag the sidebar beneath the flow up and click the debug icon verify that messages are displaying return to the flows manager browser window and navigate to applications > containers click the view icon to show the container logs a log of streaming messages sent and received appears