Ticket #2270 (closed: fixed)

Opened 10 years ago

Last modified 5 years ago

Algorithms called from a Python Algorithm should not log themselves in history

Reported by: Mathieu Doucet Owned by: Mathieu Doucet
Priority: major Milestone: Iteration 27
Component: Python Keywords:
Cc: Blocked By:
Blocking: Tester: Martyn Gigg

Description

Sub-algorithms called from a C++ algorithm don't log themselves into the workspace history. Algorithms called from python algorithms do. There should be a way to turn that off so that only the calling algorithm is logged. The calling algorithm is currently not logged.

Change History

comment:1 Changed 10 years ago by Mathieu Doucet

  • Owner set to Mathieu Doucet
  • Status changed from new to accepted

comment:2 Changed 10 years ago by Mathieu Doucet

(In [9015]) Exposed createSubAlgorithm to python. Re #2270

comment:3 Changed 10 years ago by Mathieu Doucet

(In [9034]) Added an executeSubAlg() method to PythonAlgorithm. It creates and runs a sub-alg with the provided parameters. Re #2270

comment:4 Changed 10 years ago by Mathieu Doucet

(In [9035]) Fix bad error message. Re #2270

comment:5 Changed 10 years ago by Mathieu Doucet

(In [9036]) Fixed minor bug/typo Re #2270

comment:6 Changed 10 years ago by Mathieu Doucet

(In [9052]) Properly convert pars to string. Re #2270

comment:7 Changed 10 years ago by Mathieu Doucet

(In [9054]) Added test for new python alg functionality. Re #2270

comment:8 Changed 10 years ago by Mathieu Doucet

  • Status changed from accepted to verify
  • Resolution set to fixed

PythonAlgorithms can now execute a sub-algo that will behave like those called from a C++ Algorithm (among other things, they won't log themselves). Private methods have been added to transfer ownership of the intermediate workspaces. Those could eventually go away if we add the functionality to get/set Algorithm properties in their correct type instead of using strings.

Example code from PythonAlgorithm.PyExec:

a = self.executeSubAlg(CreateWorkspace, OutputWorkspace=output_ws, DataX=[0,1,2], DataY=[0,1,2], DataE=[0,0,0])
self._setWorkspaceProperty("OutputWorkspace", a._getWorkspaceProperty("OutputWorkspace"))

See test/PythonAlgorithmTest.py for unit tests.

comment:9 Changed 10 years ago by Mathieu Doucet

(In [9056]) skip test until I figure out why it fails. Re #2270

comment:10 Changed 10 years ago by Mathieu Doucet

(In [9058]) Fixing test. Re #2270

comment:11 Changed 10 years ago by Mathieu Doucet

(In [9059]) Fixing test. Re #2270

comment:12 Changed 10 years ago by Mathieu Doucet

(In [9061]) skip test until I figure out why it fails. Re #2270

comment:13 Changed 10 years ago by Mathieu Doucet

(In [9065]) Fix issue with older version of python. Re #2270

comment:14 Changed 10 years ago by Mathieu Doucet

(In [9066]) This now should pass... finally. Re #2270

comment:15 Changed 10 years ago by Mathieu Doucet

(In [9091]) Small change to allow a PythonAlg to call a PythonAlg as a sub-alg. Re #2270

comment:16 Changed 10 years ago by Martyn Gigg

  • Status changed from verify to verifying
  • Tester set to Martyn Gigg

comment:17 Changed 10 years ago by Martyn Gigg

  • Status changed from verifying to closed

Tested in 1.1.9533

Tested with

class SubAlgTest(PythonAlgorithm):
	
	def PyInit(self):
		self.declareProperty("Value",1,Direction=Direction.Input)
		self.declareWorkspaceProperty("OutputWorkspace","",Direction=Direction.Output)
		
	def PyExec(self):
		value = self.getProperty("Value")
		child = self.executeSubAlg(CreateWorkspace,DataX=[value],DataY=[value],DataE=[value])
		self.setProperty("OutputWorkspace", child._getWorkspaceProperty("OutputWorkspace"))
		
mtd.registerPyAlgorithm(SubAlgTest())

Verified that CreateWorkspace did not log or store it's workspace in the ADS.

comment:18 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 3117

Note: See TracTickets for help on using tickets.