Skip to content

Commit

Permalink
hotfix(initialization): accessing attr "items" does not exist
Browse files Browse the repository at this point in the history
so let's guard it in an if statement for now

that block of code is a smell anyways TODO'd to be refactored
  • Loading branch information
wiwichips committed Sep 24, 2024
1 parent cf6e4db commit c953449
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions dcp/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ def init_dcp_module(py_parent, js_module, js_name):
# add the new module as a submodule of the root module
setattr(py_parent, underscore_name, module)

for prop_name, prop_ref in js_module.items():
# modify props if required
# TODO: should this be a dict of prop_name and list of modules with overridden ref?
# TODO: maybe stuff like this should be specified in one places instead of spat throughout the codebase
# TODO: tldr, should be more dry... somehow... figure out later...
if prop_name == 'fetchResults' and (js_name == 'compute' or js_name == 'job'):
setattr(module, prop_name, api.fetch_results_maker(prop_ref))
elif prop_name == 'addSlices' and js_name in ('compute', 'job'):
setattr(module, prop_name, api.add_slices_maker(prop_ref))
else:
setattr(module, prop_name, _wrap_js(prop_name, prop_ref))
if hasattr(js_module, 'items'):
for prop_name, prop_ref in js_module.items():
# modify props if required
# TODO: should this be a dict of prop_name and list of modules with overridden ref?
# TODO: maybe stuff like this should be specified in one places instead of spat throughout the codebase
# TODO: tldr, should be more dry... somehow... figure out later...
if prop_name == 'fetchResults' and (js_name == 'compute' or js_name == 'job'):
setattr(module, prop_name, api.fetch_results_maker(prop_ref))
elif prop_name == 'addSlices' and js_name in ('compute', 'job'):
setattr(module, prop_name, api.add_slices_maker(prop_ref))
else:
setattr(module, prop_name, _wrap_js(prop_name, prop_ref))


def make_init_fn(dcp_module) -> Callable:
Expand Down

0 comments on commit c953449

Please sign in to comment.