A runtime for python-based Knowledge Objects
Project description
kgrid-python-runtime
KGrid runtime for Knowledge Objects in python
Getting started:
-
Install Python 3.8 or higher
-
Install pip
-
Run
python -m pip install kgrid-python-runtime
to download the latest package -
Create a directory called
pyshelf
in the directory the runtime will be running from. -
To start the server run
python -m kgrid_python_runtime
-
If this runtime will not be running locally, you must specify the address with
KGRID_PYTHON_ENV_URL
. This will be the address given to the Kgrid Activator upon activation. -
The runtime starts on port 5000, but can be specified with
KGRID_PYTHON_ENV_PORT
-
By default, the python runtime points to a Kgrid activator at url:
http://localhost:8080
.This can be customized by setting the environment variable:
KGRID_PROXY_ADAPTER_URL
-
By default, the python runtime will tell the Kgrid Activator that it is started at
http://localhost:5000
.If you're starting the runtime at a different address, that url must be specified by setting the environment variable:
KGRID_PYTHON_ENV_URL
-
The
KGRID_PYTHON_CACHE_STRATEGY
can take three values:never
,always
, oruse_checksum
never
or if no value is set means that existing objects will be overwritten whenever objects are re-downloaded from the activator.always
means that existing objects stored in the python runtime will never be re-downloaded from the activator and the local pyshelf and context.json files must be deleted and the runtime restarted for the objects to be replaced.use_checksum
means that objects will look for a checksum in the deployment descriptor sent over during activation and only re-download the object if that checksum has changed.
To run the tests:
python -m unittest discover -s tests
##Creating a python Knowledge-Object: Just like other knowledge objects, python objects have 4 basic parts: service.yaml, deployment.yaml, metadata.txt, and a payload that can be any number of python files.
The packaging spec for knowledge objects can be found here.
If your python package requires other python packages,
simply specify them in a file called requirements.txt
at the root of your object thusly:
package-name=0.1.5
other-package-name=1.3.5
third-package-name=1.5.4
That's it! as long as the payload is written in valid python, and the object is built to the spec, you're ready to go. An example python object can be found in the example collection
Important Notes
- Editing the cache directly from the runtime's shelf will not propagate changes to the endpoints in the runtime. New KOs must come from the activator.
Project details
Release history Release notifications | RSS feed
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 kgrid-python-runtime-0.0.12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cb5a9aa2bf52a2516cd727abf55a3f33651d7261eca5c31028c68aa83f55de1 |
|
MD5 | 090a2eba4c84056cf6851626a75402a2 |
|
BLAKE2b-256 | ce6e838d6dcf9a7099235627337a42d0faaea887f44264ac084343d78fab289d |
Hashes for kgrid_python_runtime-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d87272d09ec7ed1ed47d728a9a73d46a0a74f083bb3d0961f776f56a8ad9da6 |
|
MD5 | 85a47505042f126745ea4a8e3aeacd19 |
|
BLAKE2b-256 | aaf00a72dd064f089f4f424080318f8848d4310718972f6cf7008c51fada8196 |