SDK for creating postprocessing commands
- [Optional] Miniconda
-
[Optional] Create python virtual environment. You may just use existing Python 3.9.7 if it is installed in the system.
conda create -p ./venv -y conda install -p ./venv python==3.9.7 -y conda activate ./venv
-
Install postprocessing_sdk from ISGNeuro Python index
python3 -m pip install postprocessing_sdk \ --extra-index-url http://s.dev.isgneuro.com/repository/ot.platform/simple \ --trusted-host s.dev.isgneuro.com
-
Configure
otl_v1
command to connect with otl platformcp venv/lib/python3.9/site-packages/postprocessing_sdk/pp_cmd/otl_v1/config.example.ini venv/lib/python3.9/site-packages/postprocessing_sdk/pp_cmd/otl_v1/config.ini vi venv/lib/python3.9/site-packages/postprocessing_sdk/pp_cmd/otl_v1/config.ini
Example:
[spark] base_address = http://localhost username = admin password = 12345678 [caching] # 24 hours in seconds login_cache_ttl = 86400 # Command syntax defaults default_request_cache_ttl = 100 default_job_timeout = 100
-
Launch post-processing interpreter
pp
-
Make sure that
otl_v1
command works:pp Storage directory is /tmp/pp_cmd_head/storage Commmands directory is /tmp/pp_cmd_head/pp_cmd query: | otl_v1 <# makeresults count=100 #> | head 5
Type
exit
or\q
to exit from interpreter -
Create new post-processing command
pp_create_cmd <command_name> <parent directory for repository>
-
Write your code in
command.py
. Example:import logging import pandas as pd from otlang.sdk.syntax import Keyword, Positional, OTLType from pp_exec_env.base_command import BaseCommand, Syntax log = logging.getLogger('pp_exec_env.head2') DEFAULT_NUMBER = 10 class HeadCommand(BaseCommand): # define syntax of your command here syntax = Syntax( [ Positional("number", required=True, otl_type=OTLType.INTEGER), ], use_timewindow=False # if true keyword argument 'tws' and 'twf' will be added ) def transform(self, df: pd.DataFrame) -> pd.DataFrame: number = self.get_arg('number').value return df.head(number or DEFAULT_NUMBER)
-
Create command archive for deploying on post-processing computing node:
make pack