Package: nope-py
NoPEA Python wrapper for the LibraryPlease visit ourDocuShow meNoPEin 5 Minutes!1. Create aNodejsProjectGet started bycreating a new projectdistributed usingNoPE.For ourPYTHONproject we will use the nope-js-node cli tools to create a Project.Installation using  npm:npminstall-gnope-js-nodeStart your first Project:nope-jsprojectcreateThis should open acli.Answer the requried questions to complete create the directory.Name the projectHelloWorldGive it a short summary. This summary will used during distributing your project.make shure you selectpythonas project typenavigate to the create folder ( e.g.cd ./HelloWorld)This creates a project structure.Open your IDE (e.g. vscode)By using the project-tool the following features are added to the project:Debugging of the application using VS code (launch-file)Creation of a doc file (see doc/make)Helpers to build a browser related versionUse of a changelogDeployment as a packageSimple extension using project-tool2. Add a Service inPythonOur goal is to define a greeting serviceThe service creates a greeting message for a person.Why a ServiceThis service is independent of how many times it has been called.
Our functionality is stateless, this allows us to use a service.Using theCLIto generate the ServiceTo create the Service:
use theproject-toolto create the servicenope-jsprojecteditPerfom the following selection inside of the tool.Selectionadd, to add a new elementSelectservice, because we want to create a serviceEnter the name of the service, in our caseHelloWorldCreation of the corresponding files and imports is done automaticallyThis will update our project folder.NowNoPEdefined a new service file (HelloWorldFunctions.py) for us:#!/usr/bin/env python# @author Martin Karkowski# @email m.karkowski@zema.defromnopeimportgetNopeLoggerLOGGER=getNopeLogger("HelloWorldService")# Please provide the schema for the Function.# See the Example below.SCHEMA={"type":"function",# To describe the used inputs of a function or serive we added the field "inputs" to the schema.# It contains a list of all required inputs."inputs":[],# To describe the return of a function we added the field "outputs". It contains a# JSON-Schema Object."outputs":{}}asyncdefHelloWorld(greetings:str):# Please overwrite me!LOGGER.debug("calling service 'HelloWorld' with the following parameters:"+str(greetings))return"Hello "+greetings+"!"In that file, you will find a template for the service we want to implement. By default, the newly created service implements the hello-world behavior. This must changed. In our case it matches the desired behavior.All servicesmustbe implementedasyncmanner. This is necessary so that the runtime is not blocked.Adding a Service interfaceWe now want to describe our service, that it can be used correctly at different Runtimes. Therefore we will define theschemato theSCHEMAvariable. This Schema follows the definition of aJSON-Schema:SCHEMA={"type":"function",# To describe the used inputs of a function or serive we added the field "inputs" to the schema.# It contains a list of all required inputs."inputs":[{# The Description of the Parameter"description":"The name which should receive a Greeting",# Its used name in the function (see the arguments of the function)"name":"greetings",# The Schema follows a default JSON-Schema"schema":{"type":"string"}}],# To describe the return of a function we added the field "outputs". It contains a# JSON-Schema Object."outputs":{"type":"string",# We provide some extra Info for the other users."description":"The greeting Message!"}}Because the python implementation is lacking some typings please checkout the docs3. Running the Service:To run theserviceand distribute to differentNoPE-Runtimes we have to determine a configuration:nope-pyscanThecliwill find all definedservicesormodulesexposed in a so calledNoPE-Package(This has been created automatically during the initalization of the project). The tool will store its results in the following configuration (located at./config/config.json):[{"nameOfPackage":"HelloWorld","autostart":{},"defaultInstances":[],"providedServices":[{"options":{"schema":{...},"resultSink":null,"timeout":-1,"id":"HelloWorld","ui":{"file":false,"autoGenBySchema":false,"requiredProvidersForRendering":[]},"isDynamic":false}}],"providedClasses":[],"requiredPackages":[],"path":"C:\\Users\\m.karkowski\\Documents\\00-Repos\\TEST\\HelloWorld\\HelloWorld\\__init__.py"}]Finally we are ready to distribute our service by using the command:nope-pyrunThis will start a runtime providing our service.4. Interact with the RuntimeCurrently our service is only run internally (nope is not connected and runs without an external connection layer). To check and play with the distribution, we kill our old process (ctrl+c) create a separate process (e.g. a bash) and provide a serve:nope-jsrun-cio-serverThis will spool up asocket-ioserver on our localhost.Afterwards we will restart our Runtime hosting the created service usingio-socketsas connection layer:nope-pyrun-cio-clientNow we are able to start ourinteract-toolto manually execute our process:nope-jsinteract-cio-client-sTo use theinteract-toolfollow the questions:What do you want to do?We want to inspect our distributed system ->inspectWhat do you want to inspect?We want to check if our service is present ->serviceWe should be albe to see ourHelloWorld-Service (see 1)Now we want to execute this service. Therefore we navigatebackto the main menuNow we selectexecuteand afterwardsservicebecause we want to execute our serviceNow the Tool renders the available services and we selectHelloWorld(see 2) and it will render the previously defined Schema.Now we have to enter the inputs required by the Service:It is important that the parameters are entered as list (because there might be more the 1 Parameter)Enter the parameters as validJSONData.PressenterExecuting services with the interact tool will perfom function immedialty. If you integrated Hardware be aware of that.The Tool shows the result (see 4)You are now running a distributed System usingremote procedure callsinpython