Ticket #4219 (reopened)

Opened 9 years ago

Last modified 5 years ago

Import a python variable into the current scope when a workspace is added to the ADS

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Backlog
Component: Python Keywords:
Cc: Blocked By:
Blocking: Tester:

Description

We will only implement this inside MantidPlot as there is no use for it outside of the GUI.

Change History

comment:1 Changed 9 years ago by Martyn Gigg

  • Status changed from new to accepted

comment:2 Changed 9 years ago by Martyn Gigg

At the same time the separate Python scopes will disappear in order to provide a consistent view on to Mantid from Python.

comment:3 Changed 9 years ago by Martyn Gigg

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

comment:4 Changed 9 years ago by Martyn Gigg

  • Status changed from verify to reopened
  • Resolution fixed deleted

Clicked fix on the wrong ticket

comment:5 Changed 9 years ago by Martyn Gigg

Refs #4219. Tidy up WorkspaceObserver code.

Too much of it was in the header, moved most of it to the cpp file and added extra swicthes for controlling obervations

Changeset: e1096ff0af66b0ad98a93d93c9a7d298afcb763a

comment:6 Changed 9 years ago by Martyn Gigg

Refs #4219. Fix scope of function evaluation.

Changeset: 6ea22dff91b482cbbb6e0b9c9b5e274d4e1dfe02

comment:7 Changed 9 years ago by Martyn Gigg

Refs #4219. Add python var to scope when workspace is added.

The PythonScripting enviroment in MantidPlot listens to ADS add updates and introduces a variable of the same name as the workspace into the current Python scope.

Changeset: 46afa3b7a0f99be778eb281968b7ea3bc51c2272

comment:8 Changed 9 years ago by Martyn Gigg

Refs #4219. Disable python var addition temporarily.

It seems to cause race conditions in the Muon (and probably other) interfaces.

Changeset: 8a598e18fb314d38ce63c206d3d9a2daff06a40a

comment:9 Changed 9 years ago by Martyn Gigg

Refs #4219. Allow the ADS to ban characters from names.

The ADS can set a string of characters each of which is not allowed to be present within a workspace name. The current value is an empty string and this will have some kind of default setting in the nearer future.

Changeset: fd38fd6b5e9197136091c5dfc45983ad5121e171

comment:10 Changed 9 years ago by Martyn Gigg

Refs #4219. Unify MantidPlot Python scope.

Ensures module level functions get put into the global dictionary so that other functions in the same script can call them. Without this they get put in the current scope locals which doesn't get passed to each function when it is called.

Changeset: 16ff228c9fb7b4b3c7a0cc541dd386e60e15fcd1

comment:11 Changed 9 years ago by Martyn Gigg

  • Status changed from reopened to accepted

comment:12 Changed 9 years ago by Martyn Gigg

Refs #4219. MantidPlot creates a Python variable for each workspace

The workspace must have a valid name wrt Python's variable naming rules. If it does not it currently does nothing.

Changeset: d8c462f6d7b389c9a3aa739fdadf63b581dada57

comment:13 Changed 9 years ago by Martyn Gigg

Refs #4219. Speed up MantidPlot autocomplete.

The function inspection now checks the additional varargs,kwargs returned by getargspec rather than attempting to create an algorithm.

Changeset: 0937a53968865aa6809f5894242f26d5d928f5ec

comment:14 Changed 9 years ago by Martyn Gigg

Refs #4219. Add unit test generation to python_export_maker.

Changeset: 89f39f1f5b68ee2b699b81ad4dd976639468e4e8

comment:15 Changed 9 years ago by Martyn Gigg

Refs #4219. Bounded validator python exports

Changeset: 5d150454c4d0b757ce3dd0ac3af75480884214b2

comment:16 Changed 9 years ago by Martyn Gigg

Refs #4219. Disable Python variable import while it crashes things.

Changeset: 4237c207c9ba76cf087dc6d525fb006d35cfc4f9

comment:17 Changed 9 years ago by Martyn Gigg

Refs #4219. Put back separate Python scopes.

While we need to mix-and-match the new/old Python we need each script to be able to maintain its own scope.

Changeset: 92dab81a7261aa23503d767d1679ddf2fb9006c9

comment:18 Changed 9 years ago by Martyn Gigg

Refs #4219. Fix the MantidPlot tests.

Changeset: 97aad265aee301ffceb1cb59977c77b082fb5eb4

comment:19 Changed 9 years ago by Martyn Gigg

Refs #4219. Formatting changes only.

Changeset: f06a05b8dbf4b6b1c6262b9b8ce898057565cf7a

comment:20 Changed 9 years ago by Martyn Gigg

Refs #4219. Add an option to have the new-style Python by default.

Changeset: 73d3ecf8cdd874b0bf76735b01bc4253ff9647d5

comment:21 Changed 9 years ago by Martyn Gigg

Refs #4219. Plotting now doesn't care which Python is used.

The functions now check for attributes rather than specific objects so that they can work transparently with whichever Python api is loaded

Changeset: 8c10294849ce7af6844e05cdf4ffb9ae773d8692

comment:22 Changed 9 years ago by Martyn Gigg

Refs #4219. Fix the MantidPlot tests.

Changeset: df984d3da79a6511c740bef37720bca1cb81a4c1

comment:23 Changed 9 years ago by Martyn Gigg

Refs #4219. Add back in option for backwards compatability.

Changeset: 65ab4588725ede1d58bfdf808c1e10b4d8e86061

comment:24 Changed 9 years ago by Martyn Gigg

Add ADS observers for each python scope. Refs #4219

Changeset: c0006de3942f93d4bb22b661f0b6ee73f918a181

comment:25 Changed 9 years ago by Mathieu Doucet

Re #4219 AddPythonReference still makes MantidPlot crash randomly

Changeset: dd654b1276024e85185cccbcc0c65650c6fb9523

comment:26 Changed 9 years ago by Martyn Gigg

Mathieu,

I don't suppose you have a reproducible example to get it to crash do you or is it completely random as your commit message suggests? I can't seem to get it to crash myself.

comment:27 Changed 9 years ago by Martyn Gigg

Refs #4219. Disable ADS observers while the random crashes occur

Changeset: c3ac9471c84846a06b30f62f15abbdb3a5c78f87

comment:28 Changed 9 years ago by Mathieu Doucet

Martyn, Try running the following code in the scripting window. Just replace the path in the DataPath command to point to your Mantid Test/Data/SANS2D directory.

from MantidFramework import *
mtd.initialise(False)
from reduction.instruments.sans.hfir_command_interface import *

BIOSANS()
DataPath("/home/m2d/git/mantid/Test/Data/SANS2D")
SetSampleDetectorOffset(837.9)
SolidAngle()
DarkCurrent("BioSANS_dark_current.xml")
MonitorNormalization()
AzimuthalAverage(n_bins=100, n_subpix=1, log_binning=True)
IQxQy(nbins=100)
DirectBeamCenter("BioSANS_empty_cell.xml")
SensitivityCorrection("BioSANS_flood_data.xml", min_sensitivity=0.5, max_sensitivity=1.5, use_sample_dc=False)
DivideByThickness(1)
DirectBeamTransmission("BioSANS_sample_trans.xml", "BioSANS_empty_trans.xml", beam_radius=3)
ThetaDependentTransmission(True)
AppendDataFile(["BioSANS_exp61_scan0004_0001.xml"])
Background("BioSANS_test_data.xml")
SetBckTransmission(1, 0)
BckThetaDependentTransmission(True)
SaveIqAscii()
Reduce1D()

comment:29 Changed 9 years ago by Martyn Gigg

Refs #4219. Turn back on python variable creation.

I have run a script that was crashing in a tight loop and it doesn't crash for me now.

Changeset: 8a1316242e48623c574598c530682b8ea4a1b8ec

comment:30 Changed 9 years ago by Martyn Gigg

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

comment:31 Changed 9 years ago by Martyn Gigg

  • Status changed from verify to reopened
  • Resolution fixed deleted

comment:32 Changed 9 years ago by Martyn Gigg

Refs #4219. Disable Python scope imports.

They are still not reliable everywhere so move to next iteration

Changeset: 54cd1448552c3e00bf5fbc6caf18e1c43acc145e

comment:33 Changed 9 years ago by Martyn Gigg

  • Milestone changed from Iteration 32 to Iteration 33

comment:34 Changed 8 years ago by Martyn Gigg

  • Milestone changed from Release 2.1 to Release 2.2

comment:35 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:36 Changed 8 years ago by Martyn Gigg

  • Priority changed from blocker to major

comment:37 Changed 8 years ago by Martyn Gigg

  • Milestone changed from Release 2.3 to Release 2.4

comment:38 Changed 8 years ago by Martyn Gigg

  • Milestone changed from Release 2.4 to Release 2.5

comment:39 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:40 Changed 7 years ago by Martyn Gigg

  • Milestone changed from Release 2.6 to Release 2.7

Batch move to 2.7

comment:41 Changed 7 years ago by Nick Draper

  • Milestone changed from Release 2.7 to Backlog

comment:42 Changed 7 years ago by Nick Draper

  • Component changed from Mantid to Framework

comment:43 Changed 7 years ago by Nick Draper

  • Component changed from Framework to Python API

comment:44 Changed 7 years ago by Nick Draper

  • Milestone changed from Backlog to Release 3.0

moved to Release 3.0 as these all seem to be active

comment:45 Changed 7 years ago by Martyn Gigg

  • Milestone changed from Release 3.0 to Backlog

comment:46 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 5066

Note: See TracTickets for help on using tickets.