You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There has been some discussion on Slack about the following so i decided to create an issue to track requirements and investigations.
Use Case:
There is a pack deployed that has some code in actions/lib/common.py that implements some common functionality
Within this pack an action exists actions/example_action.py that utilizes the common code in actions/lib/common.py
Within the same pack a sensor exists in sensors/example_sensor.py that also needs to utilize the common code in actions/lib/common.py
Problem:
This common code is not available to both the sensor and action at the same time within the same pack
Ideas:
Place the code in some "common" area (/opt/stackstorm/common/xxx) and setup symlinks to the code in both the /opt/stackstorm/packs/<pack_name>/actions/lib and /opt/stackstorm/packs/<pack_name>/sensors/lib directories.
Place the code into a "common" python module that can be installed via pip using requirements.txt (this can support both public modules and installing from private git repos)
Something else (may allowing packs to access code from other packs?)
The text was updated successfully, but these errors were encountered:
/opt/stackstorm/packs/<pack>/
common_lib/
__init__.py
common_foobar.py
actions/
lib/ <= directory
__init__.py <= symlink to ../../common_lib/__init__.py
common_foobar.py <= symlink to ../../common_lib/common_foobar.py
action.py <= not shared, not a symlink
sensor/
lib/ <= directory
__init__.py <= symlink to ../../common_lib/__init__.py
common_foobar.py <= symlink to ../../common_lib/common_foobar.py
action.py <= not shared, not a symlink
edit: swapped out the / directory for /common_lib to make it clearer
I looked into using relative links in requirements.txt to grab some lib folder in a different directory, but pip doesn't support relative links in any sane fashion right now (see pypa/pip#328 which is fixed partially by pypa/pip#4208, but is not in any released version yet).
It looks like, if the common_lib dir (or whatever you choose to call it) is included in requirements.txt as ./common_lib (not ./common_lib#egg....) then it should work (I haven't tested yet, I'm just noting my thoughts).
I wonder, is it possible for pip to use a custom URI scheme? Maybe we could register st2:// as a custom scheme, and then we add requirements using st2://<pack>/dir/in/pack.
There has been some discussion on Slack about the following so i decided to create an issue to track requirements and investigations.
Use Case:
actions/lib/common.py
that implements some common functionalityactions/example_action.py
that utilizes the common code inactions/lib/common.py
sensors/example_sensor.py
that also needs to utilize the common code inactions/lib/common.py
Problem:
Ideas:
/opt/stackstorm/common/xxx
) and setup symlinks to the code in both the/opt/stackstorm/packs/<pack_name>/actions/lib
and/opt/stackstorm/packs/<pack_name>/sensors/lib
directories.pip
usingrequirements.txt
(this can support both public modules and installing from private git repos)The text was updated successfully, but these errors were encountered: