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
Built Distribution
Hashes for democrite-4.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31198e04adf8823b16907a7560f9b8fdf268f1521045c485801cac3fc6f47364 |
|
MD5 | c3937c19e0eb81cba9c7864be2f7c327 |
|
BLAKE2b-256 | 65774c0dcfc4c03bee6da9ea83d557d6dbbbb57d530b0e2826152a1f21298f91 |