chaostoolkit icon indicating copy to clipboard operation
chaostoolkit copied to clipboard

Not able to invoke python module

Open surajpanda1582 opened this issue 4 years ago • 3 comments

I have written python script for steady state hypothesis check. Script name is chaosSteadyStateTest.py and inside this multiple functions are there. I added a setup file and installed the script using pip install -e

When I tried to invoke the python function during chaos run it is giving me error. [2021-11-09 16:08:07 ERROR] could not find Python module 'C:\Users\SP889\workspace\ChaosMonkey\ChaosPythonScript\chaosSteadyStateTest' in activity 'we-can-probe-service'

Here is my experiments.json

"probes": [ { "type": "probe", "name": "we-can-probe-service", "tolerance": 200, "provider": { "type": "python", "module": "chaosSteadyStateTest", "func": "copyfile", "arguments": { "path": "myfile.txt" } } } ]

I have added the module path in PYTHONPATH as env variable on windows 10 , kept python module file next to experiment.json as well still giving same error Can someone please help how to invoke python function from here.

surajpanda1582 avatar Nov 09 '21 10:11 surajpanda1582

This is not a ChaosToolkit issue but depends on your Python environment. How do you run tests ? As the error message says the chaos runtime can't find your module under the C:\Users\SP889\workspace\ChaosMonkey\ChaosPythonScript\ directory.

Moreover, by your configuration, it seems to me that you are not following what specified by the documentation https://chaostoolkit.org/reference/extending/extending-with-python/.

Please follow the documentation carefully.

grubert65 avatar Nov 09 '21 14:11 grubert65

I have followed the below thread to call python function for my steady state hopethesis probe. I have added my python module in PYTHONPATH environment variable as per the documentation below. https://chaostoolkit.org/reference/tutorials/extend/#create-a-simple-python-function

The below link is for extending chaos toolkit. Is it applicable to call simple python function for steady state analysis? From here I am not clearly getting how my python script chaosSteadyStateTest.py can be called. https://chaostoolkit.org/reference/extending/extending-with-python/

surajpanda1582 avatar Nov 10 '21 07:11 surajpanda1582

@surajpanda1582 what does the contents of your file look like? Are you able to share it?

ciaransweet avatar Nov 29 '21 13:11 ciaransweet

This Issue has not been active in 365 days. To re-activate this Issue, remove the Stale label or comment on it. If not re-activated, this Issue will be closed in 7 days.

github-actions[bot] avatar Dec 04 '22 01:12 github-actions[bot]

This Issue was closed because it was not reactivated after 7 days of being marked Stale.

github-actions[bot] avatar Dec 11 '22 01:12 github-actions[bot]