Skip to content

Commit

Permalink
Fixes to get machine mappings working for other experiments again
Browse files Browse the repository at this point in the history
Source all compatible machines, protect against any that aren't,
add missing dependencies, and include missing checks
  • Loading branch information
torrinba committed Mar 29, 2024
1 parent 216cd7e commit 931f2a2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions omas/machine_mappings/d3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from omas.utilities.omas_mds import mdsvalue
from omas.omas_core import ODS
from omas.omas_structure import add_extra_structures
from omas.omas_physics import omas_environment

__all__ = []
__regression_arguments__ = {'__all__': __all__}
Expand Down
2 changes: 2 additions & 0 deletions omas/machine_mappings/east.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from omas import *
from omas.omas_utils import printd
from omas.machine_mappings._common import *
from omas.utilities.machine_mapping_decorator import machine_mapping_function
from omas.utilities.omas_mds import mdsvalue

__all__ = []
__regression_arguments__ = {'__all__': __all__}
Expand Down
2 changes: 2 additions & 0 deletions omas/machine_mappings/mast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from omas import *
from omas.omas_utils import printd, printe, unumpy
from omas.machine_mappings._common import *
from omas.utilities.machine_mapping_decorator import machine_mapping_function
from omas.omas_core import ODS
import glob
import pyuda

Expand Down
4 changes: 4 additions & 0 deletions omas/machine_mappings/nstxu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from omas import *
from omas.omas_utils import printd, printe, unumpy
from omas.machine_mappings._common import *
from omas.utilities.machine_mapping_decorator import machine_mapping_function
from omas.utilities.omas_mds import mdsvalue
from omas.omas_core import ODS
from omas.omas_physics import omas_environment
import glob

# NOTES:
Expand Down
5 changes: 4 additions & 1 deletion omas/omas_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .omas_utils import *
from .omas_core import ODS, dynamic_ODS, omas_environment, omas_info_node, imas_json_dir, omas_rcparams
from .omas_physics import cocos_signals
from omas.machine_mappings import d3d
from omas.machine_mappings import d3d, nstx, nstxu, east
from omas.machine_mappings.d3d import __regression_arguments__
from omas.utilities.machine_mapping_decorator import machine_mapping_function
from omas.utilities.omas_mds import mdsvalue
Expand Down Expand Up @@ -215,6 +215,9 @@ def resolve_mapped(ods, machine, pulse, mappings, location, idm, options_with_d

# PYTHON
elif 'PYTHON' in mapped:
if 'mast' in machine:
printe(f"MAST is currently not supported because of UDA", topic='machine')
return ods
call = mapped['PYTHON'].format(**options_with_defaults)
# python functions tend to set multiple locations at once
# it is thus very beneficial to cache that
Expand Down
11 changes: 7 additions & 4 deletions omas/utilities/machine_mapping_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ def machine_mapping_caller(*args, **kwargs):
default_options = {item: value for item, value in default_options.items() if not item.startswith('_')}

# call
update_mapping = kwargs.pop("update_callback")
update_mapping = None
if "update_callback" in kwargs:
update_mapping = kwargs.pop("update_callback")
out = f(*args, **kwargs)
#update mappings definitions
if clean_ods and omas_git_repo:
for ulocation in numpy.unique(list(map(o2u, args[0].flat().keys()))):
update_mapping(machine, ulocation, {'PYTHON': call}, 11, default_options, update_path=True)
if not update_mapping is None:
if clean_ods and omas_git_repo:
for ulocation in numpy.unique(list(map(o2u, args[0].flat().keys()))):
update_mapping(machine, ulocation, {'PYTHON': call}, 11, default_options, update_path=True)

return out

Expand Down

0 comments on commit 931f2a2

Please sign in to comment.