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.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b26bff3ad8f16777971214b129c0294c369484fbd130d9a6f6c47716fcf62e9a |
|
MD5 | e5bcd715296dd68b3c2f3172408311a5 |
|
BLAKE2b-256 | 83eebcbc15dc0c42980b8a0dd928a1057946a45487db2fd1f86488b7ff9b32aa |