Ticket #4873 (closed: fixed)
Create an algorithm that will run a snippet of python code
Reported by: | Janik Zikovsky | Owned by: | Janik Zikovsky |
---|---|---|---|
Priority: | major | Milestone: | Release 2.1 |
Component: | Mantid | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #4787 | Tester: | Stuart Campbell |
Description (last modified by Janik Zikovsky) (diff)
This is for use in LoadLiveData.
This would be an algorithm with 3 properties:
- InputWorkspace (optional)?
- Code
- OutputWorkspace (optional)?
The algorithm would:
- Have a method for validating the syntax of the code (validator?)
- Run the python code in its exec() method.
- Redirect stdout, stderr, and exceptions/python errors to the algorithm logger.
[Edit]: Since it seems that such an algorithm cannot run within python, I am using a Python algorithm instead. It can still be used in LoadLiveData within MantidPlot.
Change History
comment:2 Changed 9 years ago by Nick Draper
- Status changed from new to assigned
- Owner set to Janik Zikovsky
Ok i'm clear on this one as long as it is an additional option as well as py Algs.
comment:4 Changed 9 years ago by Janik Zikovsky
Refs #4873 first stab at RunPythonScript C++ algorithm
Changeset: 32b971375668b8df5d577c9ae70d93f0ed075c6e
comment:5 Changed 9 years ago by Janik Zikovsky
- Description modified (diff)
- Summary changed from Create a C++ algorithm that will run a snippet of python code to Create an algorithm that will run a snippet of python code
comment:6 Changed 9 years ago by Janik Zikovsky
Refs #4873 Python Algorithm to run a snippet of python code
The C++ algorithm works, but you cannot start a python script that launches the C++ RunPythonScript to run python (I imagine you can't have two python instances running at the same time)
Changeset: 7b8be9d38418a6338c2469c771296ae79448f0c0
comment:7 Changed 9 years ago by Janik Zikovsky
Refs #4873 disable C++ test for RunPythonScript
Changeset: 52ba17545db016ef4574a67726dd17b925f9a654
comment:8 Changed 9 years ago by Janik Zikovsky
Refs #4873 unit test for RunPythonScript.py
Changeset: 84bd4bc9d41bc2e33036b0b9d16c703f290e5f07
comment:9 Changed 9 years ago by Janik Zikovsky
Refs #4873 remove the C++ python algorithm attempt
Changeset: 28b14821ad77421549ce1f1f78f9a94c4957acfc
comment:10 Changed 9 years ago by Janik Zikovsky
Refs #4873 handle do-nothing script in RunPythonScript.py
Changeset: 379c2a8c44e998d904bdbf61e86ceecde5c29de1
comment:11 Changed 9 years ago by Janik Zikovsky
Refs #4873 use generic Workspace properties in RunPythonScript
Refs #4915
Changeset: f67230feca6f1403e2f83cfa35ca1e4ef6039ca8
comment:12 Changed 9 years ago by Janik Zikovsky
Refs #4873 first stab at RunPythonScript C++ algorithm
Changeset: 32b971375668b8df5d577c9ae70d93f0ed075c6e
comment:13 Changed 9 years ago by Janik Zikovsky
Refs #4873 Python Algorithm to run a snippet of python code
The C++ algorithm works, but you cannot start a python script that launches the C++ RunPythonScript to run python (I imagine you can't have two python instances running at the same time)
Changeset: 7b8be9d38418a6338c2469c771296ae79448f0c0
comment:14 Changed 9 years ago by Janik Zikovsky
Refs #4873 disable C++ test for RunPythonScript
Changeset: 52ba17545db016ef4574a67726dd17b925f9a654
comment:15 Changed 9 years ago by Janik Zikovsky
Refs #4873 unit test for RunPythonScript.py
Changeset: 84bd4bc9d41bc2e33036b0b9d16c703f290e5f07
comment:16 Changed 9 years ago by Janik Zikovsky
Refs #4873 remove the C++ python algorithm attempt
Changeset: 28b14821ad77421549ce1f1f78f9a94c4957acfc
comment:17 Changed 9 years ago by Janik Zikovsky
Refs #4873 handle do-nothing script in RunPythonScript.py
Changeset: 379c2a8c44e998d904bdbf61e86ceecde5c29de1
comment:18 Changed 9 years ago by Janik Zikovsky
Refs #4873 use generic Workspace properties in RunPythonScript
Refs #4915
Changeset: f67230feca6f1403e2f83cfa35ca1e4ef6039ca8
comment:19 Changed 9 years ago by Janik Zikovsky
- Status changed from accepted to verify
- Resolution set to fixed
comment:20 Changed 8 years ago by Stuart Campbell
- Status changed from verify to verifying
- Tester set to Stuart Campbell
comment:21 Changed 8 years ago by Stuart Campbell
- Status changed from verifying to closed
Seems to run ok, Just tried a simple script like
print input.blocksize()
comment:22 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 5720
Janik,
I'm not sure this is the way to go. I think we need to talk about this, I'll try to give you a call today, I'm interviewing, but should be able to fit it in between.
I still think that python algorithms are the right choice, you had concerns, but as far as I know you can run a python algorithm from within a C++ one, you just have to use the algorithm interface, and you can register changes to and additional python algorithms at run time, without having to restart MantidPlot.