Skip to content

Commit c54264c

Browse files
authored
Fixing bug fixes along with a few enhancements (#56)
1 parent 9a19f28 commit c54264c

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

docs/RELEASES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release history
22

3+
## v0.3.9 (2022-06-29)
4+
5+
- Bug fix in catalog get function, Issue 54.
6+
- Enhancement of sending log levels to different executing environments, Issue 53
7+
- Map variable sent in as environment variable to non-shell tasks, Issue 51
8+
39

410
## v0.3.8 (2022-06-29)
511

magnus/catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def get(self, name: str, run_id: str, compute_data_folder=None, **kwargs) -> Lis
216216
raise Exception(msg)
217217

218218
catalog_location = self.get_catalog_location()
219-
run_catalog = Path(catalog_location) / run_id
219+
run_catalog = Path(catalog_location) / run_id / copy_to
220220

221221
logger.debug(f'Copying objects to {copy_to} from the run catalog location of {run_catalog}')
222222

magnus/tasks.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def execute_command(self, map_variable: dict = None, **kwargs):
8888
parameters = self.get_parameters()
8989
filtered_parameters = utils.filter_arguments_for_func(f, parameters, map_variable)
9090

91+
if map_variable:
92+
os.environ[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE'] = json.dumps(map_variable)
93+
9194
logger.info(f'Calling {func} from {module} with {filtered_parameters}')
9295
try:
9396
user_set_parameters = f(**filtered_parameters)
@@ -99,6 +102,9 @@ def execute_command(self, map_variable: dict = None, **kwargs):
99102
logger.exception(_e)
100103
raise
101104

105+
if map_variable:
106+
del os.environ[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE']
107+
102108
self.set_parameters(user_set_parameters)
103109

104110

@@ -121,6 +127,9 @@ def execute_command(self, map_variable: dict = None, **kwargs):
121127
parameters = self.get_parameters()
122128
filtered_parameters = utils.filter_arguments_for_func(f, parameters, map_variable)
123129

130+
if map_variable:
131+
os.environ[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE'] = json.dumps(map_variable)
132+
124133
logger.info(f'Calling lambda function: {self.command} with {filtered_parameters}')
125134
try:
126135
user_set_parameters = f(**filtered_parameters)
@@ -132,6 +141,9 @@ def execute_command(self, map_variable: dict = None, **kwargs):
132141
logger.exception(_e)
133142
raise
134143

144+
if map_variable:
145+
del os.environ[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE']
146+
135147
self.set_parameters(user_set_parameters)
136148

137149

@@ -158,6 +170,9 @@ def execute_command(self, map_variable: dict = None, **kwargs):
158170
filtered_parameters = utils.filter_arguments_from_parameters(parameters=parameters,
159171
signature_parameters=notebook_parameters,
160172
map_variable=map_variable)
173+
if map_variable:
174+
os.environ[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE'] = json.dumps(map_variable)
175+
161176
notebook_output_path = self.config.get('notebook_output_path',
162177
''.join(self.command.split('.')[:-1]) + '_out.ipynb')
163178
kernel = self.config.get('notebook_kernel', None)
@@ -175,6 +190,10 @@ def execute_command(self, map_variable: dict = None, **kwargs):
175190
kwds['kernel_name'] = kernel
176191

177192
pm.execute_notebook(**kwds)
193+
194+
if map_variable:
195+
del os.environ[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE']
196+
178197
except ImportError as e:
179198
msg = (
180199
f'Task type of notebook requires papermill to be installed. Please install via optional: notebook'
@@ -194,9 +213,12 @@ def execute_command(self, map_variable: dict = None, **kwargs):
194213
# It might be that we have to write a bash/windows script that does things for us
195214
# Need to over-ride set parameters too
196215
subprocess_env = os.environ.copy()
216+
197217
if map_variable:
198218
subprocess_env[defaults.PARAMETER_PREFIX + 'MAP_VARIABLE'] = json.dumps(map_variable)
219+
199220
result = subprocess.run(self.command, check=True, env=subprocess_env, shell=True,
200221
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
222+
201223
print(result.stdout)
202224
print(result.stderr)

magnus/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,11 @@ def get_node_execution_command(executor, node, map_variable=None, over_write_run
442442
if over_write_run_id:
443443
run_id = over_write_run_id
444444

445+
log_level = logging.getLevelName(logger.getEffectiveLevel())
446+
445447
action = (f'magnus execute_single_node {run_id} '
446-
f'{node.command_friendly_name()} --file {executor.pipeline_file}'
448+
f'{node.command_friendly_name()} --file {executor.pipeline_file} '
449+
f'--log-level {log_level}'
447450
)
448451

449452
if executor.variables_file:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "magnus"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
description = "A Compute agnostic pipelining software"
55
authors = ["Vijay Vammi <vijay.vammi@astrazeneca.com>", "Vijay Vammi <mesanthu@gmail.com>"]
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)