Skip to main content

Library use to construct VGrain to democrite servers

Project description

Democrite

This library permit to create VGrain for using en Democrite environment.

Installation

pip install democrite

How to use

Your grain could be used in two mode :

  • OneShot: Script mode, the script is execute at each request
  • Deamon: The script is start and stay alive to perform request

Create VGrain

To start you need to create a vgrain object with command line argument pass in parameters

import democrite

app = democrite.vgrain(sys.argv)

Create function

You need to pass a function to execute each request

def execFunc(command: democrite.vgrainCommand, tools: democrite.vgrainTools) -> any:

Choose Mode

OneShot

The command data are pass in command line argument in format (Json -> Base64)
The command result is returned by the strandard output in format 'ExecutionId:(json -> Base64)'

app.execute(execFunc);

Deamon

A connection is made in local using the port pass in argument '--port:4242'

app.run(execFunc);

test

During you developement you need to test your code.
To do so use the test method with data you need as input.

app.test("5+6", execFunc);

vgrainCommand

The command is pass on an object exposing :

# uid unique of the flow executing the grain
vgrainCommand.get_flow_uid() -> uuid

# uid grain execution
vgrainCommand.get_execution_uid() -> uuid

# get command input
vgrainCommand.get_content() -> uuid

vgrainTools

This object provide tools dedicated to request

# provide access to a logger that will send back the logs to democrite
vgrainTools.get_logger.logInformation("LOG")

# provide the remain argument not consumed by the library
vgrainTools.get_args() -> list[str]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

democrite-4.3.0.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

democrite-4.3.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page