Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix object usage from modifier builtins #430

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,15 @@ def _get_executable_graph(self, workload_name):
if namespace.executables in self.internals:
exec_order = self.internals[namespace.executables]

builtin_objects = [self]
all_builtins = [self.builtins]
for mod_inst in self._modifier_instances:
builtin_objects.append(mod_inst)
all_builtins.append(mod_inst.builtins)

executable_graph = ramble.graphs.ExecutableGraph(exec_order, self.executables,
all_builtins, self)
builtin_objects, all_builtins,
self)

# Perform executable injection
if namespace.executable_injection in self.internals:
Expand Down Expand Up @@ -872,7 +875,7 @@ def _define_commands(self, exec_graph):

else: # All Builtins
func = exec_node.attribute
func_cmds = func(self)
func_cmds = func()
for cmd in func_cmds:
self._command_list.append(self.expander.expand_var(cmd, exec_vars))

Expand Down
16 changes: 10 additions & 6 deletions lib/ramble/ramble/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class ExecutableGraph(AttributeGraph):
node_type = 'command executable'
supported_injection_orders = enum.Enum('supported_injection_orders', ['before', 'after'])

def __init__(self, exec_order, executables, builtin_groups, obj_inst):
def __init__(self, exec_order, executables, builtin_objects, builtin_groups, obj_inst):
"""Construct a new ExecutableGraph

Executable graphs have node attributes that are either of type
Expand All @@ -241,8 +241,10 @@ def __init__(self, exec_order, executables, builtin_groups, obj_inst):
exec_order (list(str)): List of executable names in execution order
executables (dict): Dictionary of executable definitions.
Keys are executable names, values are CommandExecutables
builtins (dict): Dictionary containing definitions of builtins. Keys are names
values are configurations of builtins.
builtin_objects (list(object)): List of objects to associate with each builtin
group (in order)
builtins (list(dict)): List of dictionaries containing definitions of builtins.
Keys are names values are configurations of builtins.
modifier_builtins (dict): Dictionary containing definitions of modifier builtins.
Keys are names values are configurations of builtins.
Modifier builtins are inserted between application builtins
Expand All @@ -260,11 +262,13 @@ def __init__(self, exec_order, executables, builtin_groups, obj_inst):
super().update_graph(exec_node)

# Define nodes for builtins
for builtins in builtin_groups:
for builtin_obj, builtins in zip(builtin_objects, builtin_groups):
for builtin, blt_conf in builtins.items():
self._builtin_dependencies[builtin] = blt_conf['depends_on'].copy()
exec_node = ramble.util.graph.GraphNode(builtin, blt_conf['function'],
obj_inst=obj_inst)
blt_func = getattr(builtin_obj, blt_conf['name'])
exec_node = ramble.util.graph.GraphNode(builtin,
attribute=blt_func,
obj_inst=builtin_obj)
self.node_definitions[builtin] = exec_node

dep_exec = None
Expand Down
3 changes: 1 addition & 2 deletions lib/ramble/ramble/language/shared_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ def _store_builtin(obj):
obj.builtins[builtin_name] = {'name': name,
'required': required,
'injection_method': injection_method,
'depends_on': depends_on.copy(),
'function': getattr(obj, name)}
'depends_on': depends_on.copy()}
return _store_builtin


Expand Down
5 changes: 4 additions & 1 deletion var/ramble/repos/builtin.mock/modifiers/test-mod/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ class TestMod(BasicModifier):

register_builtin('test_builtin', required=True, injection_method='append')

test_attr = 'test_value'

def test_builtin(self):
return ['echo "fom_contextFOM_GOES_HERE" >> {analysis_log}']
return ['echo "fom_contextFOM_GOES_HERE" >> {analysis_log}',
f'echo "{self.test_attr}"' + ' >> {analysis_log}']
Loading