Ticket #4218 (closed: fixed)

Opened 9 years ago

Last modified 5 years ago

Add algorithms as methods on workspaces

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: critical Milestone: Release 3.0
Component: Python Keywords:
Cc: Blocked By:
Blocking: Tester: Nick Draper

Description (last modified by Nick Draper) (diff)

From design doc

Only algorithms specifically marked for addition to a particular DataObject will be added as methods. This will be controlled by two additional overridable methods on the base algorithm class:

  • std::string methodName() – the name the method should be called when attached to a dataobject.

for example DeteleWorkspace it would be Delete. The default would be and empty string.

  • std::string methodOn() – The class defining which DataObjects this would be a method on
  • std::string methodInputProperty() – The class defining which DataObjects this would be a method on

Change History

comment:1 Changed 9 years ago by Nick Draper

  • Milestone changed from Iteration 32 to Iteration 33

Moved to iteration 33 at iteration 32 code freeze

comment:2 Changed 8 years ago by Martyn Gigg

  • Priority changed from major to critical

comment:3 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.1 to Release 2.2

Moved at end of release 2.1

comment:4 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.2 to Release 2.3

Moved at the end of release 2.2

comment:5 Changed 8 years ago by Nick Draper

  • Milestone changed from Release 2.3 to Release 2.4

Moved to milestone 2.4

comment:6 Changed 8 years ago by Martyn Gigg

  • Milestone changed from Release 2.4 to Release 2.5

comment:7 Changed 7 years ago by Nick Draper

  • Milestone changed from Release 2.5 to Release 2.6

Moved to r2.6 at the end of r2.5

comment:8 Changed 7 years ago by Martyn Gigg

  • Milestone changed from Release 2.6 to Release 2.7

Batch move to 2.7

comment:9 Changed 7 years ago by Nick Draper

  • Milestone changed from Release 2.7 to Backlog

comment:10 Changed 7 years ago by Nick Draper

  • Component changed from Mantid to Framework

comment:11 Changed 7 years ago by Nick Draper

  • Component changed from Framework to Python API
  • Description modified (diff)

comment:12 Changed 7 years ago by Martyn Gigg

  • Milestone changed from Backlog to Release 3.0

comment:13 Changed 7 years ago by Martyn Gigg

  • Status changed from new to inprogress

Add structure to define runtime class methods on workspaces...

to algorithm base classes. Refs #4218

Changeset: 1a63ba3a96ef0852b34dee36387507f18e777244

comment:14 Changed 7 years ago by Martyn Gigg

Export algorithm workspace methods descriptors to Python. Refs #4218

Changeset: b8c87c0b43a7329f4a0a48e61f3a74ccf7d03238

comment:15 Changed 7 years ago by Martyn Gigg

Attach algorithm functions as methods when requested.

On startup, when the simple api is compiled the functions are attached to the appropriate workspace classes defined by the algorithm. Refs #4218

Changeset: 62ef5edfff4ae7396ca04d68d2ef1456d44fa040

comment:16 Changed 7 years ago by Martyn Gigg

Documentation fixes for sphinx markdown.

Refs #4218

Changeset: 04b962535d8688ff2950f47c4a88a282d3cd57b6

comment:17 Changed 7 years ago by Martyn Gigg

Generate the correct method signatures for algorithm the methods.

Refs #4218

Changeset: 16209c3cdd2684de4ddd5be2235e2e29e74b797e

comment:18 Changed 7 years ago by Martyn Gigg

Fix attribute error in _workspaceops.

The api module is not quite imported yet so don't use the aliases Refs #4218

Changeset: 7d05f0ba2f23c3e73fa67aa3d8ef0f9d49b87cb8

comment:19 Changed 7 years ago by Martyn Gigg

Expose Rebin as workspace method and use it in testing.

Refs #4218

Changeset: 775d7aa85794c6473643d8700778f770e7c30287

comment:20 Changed 7 years ago by Martyn Gigg

Fix problem when using workspace methods with positional arguments.

Refs #4218

Changeset: 146f5faf384daad1e08ac1a06594da0fc8bbb14f

comment:21 Changed 7 years ago by Martyn Gigg

Export other algorithms as methods on workspaces.

Refs #4218

Changeset: 32059522feee51d8ae14d5f6bfc12f7a86226382

comment:22 Changed 7 years ago by Martyn Gigg

Improve error message when position args are used but not needed.

Refs #4218

Changeset: 9ac8d0b306115480724768991c3ea52d3cc9086b

comment:23 Changed 7 years ago by Martyn Gigg

Export RenameWorkspace as .rename method.

Refs #4218

Changeset: 36d0e2f3ee6b2d5377bad4cb9174fe7832e82205

comment:24 Changed 7 years ago by Martyn Gigg

Branch: feature/4218_algs_as_python_methods

Tester: This covers the implementation of algorithms as methods and the exporting of a few frequently used algorithms. Others can be considered in future tickets.

This work will allow things like:

w = Load('myfile')
w.delete() ...

The algorithms exposed as methods, with their corresponding method names, currently are:

  • DeleteWorkspace --> delete
  • RenameWorkspace --> rename
  • CloneWorkspace --> clone
  • ConvertUnits --> convertUnits
  • Rebin --> rebin
  • MaskDetectors --> maskDetectors

The workspace that calls the method should get set as the input workspace and then all other arguments passed as expected to the algorithm. Basically calling the free function and the method approach on the same workspace should produce identical results given the same parameters.

comment:25 Changed 7 years ago by Martyn Gigg

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

comment:26 Changed 7 years ago by Samuel Jackson

  • Status changed from verify to verifying
  • Tester set to Samuel Jackson

comment:27 Changed 7 years ago by Samuel Jackson

  • Status changed from verifying to reopened
  • Resolution fixed deleted

Tested each of the algorithms and they appear to work fine. However, not all of the exposed algorithms appear to show up in the auto complete suggestion box when typing in the script window.

The following two did show up:

  • Rebin
  • Clone

But the others listed above did not auto complete.

comment:28 Changed 7 years ago by Martyn Gigg

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

Please retest.

comment:29 Changed 7 years ago by Samuel Jackson

  • Status changed from verify to verifying

comment:30 Changed 7 years ago by Samuel Jackson

  • Tester changed from Samuel Jackson to Nick Draper

comment:31 Changed 7 years ago by Nick Draper

  • Status changed from verifying to closed

good, but I think we may want to revisit rename and the intellisense help

comment:32 Changed 7 years ago by Nick Draper

Merge remote-tracking branch 'origin/feature/4218_algs_as_python_methods'

Full changeset: 4d4fa5f65ef2dc65d0cb572a7a836e973c996537

comment:33 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 5065

Note: See TracTickets for help on using tickets.