Skip to content

Commit

Permalink
resolved arg name conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
zilto authored and skrawcz committed Jun 1, 2024
1 parent 762128c commit 22c0373
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions hamilton/plugins/jupyter_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def resolve_config_arg(self, config_arg) -> Union[bool, dict]:
return config

@magic_arguments() # needed on top to enable parsing
@argument("module_name", nargs="?", help="Name for the module defined in this cell.")
@argument("name", nargs="?", help="Name for the module defined in this cell.")
@argument(
"-m",
"--module_name",
Expand Down Expand Up @@ -311,8 +311,15 @@ def B(A: int) -> bool:
if config is False:
return

# resolve the values of args
module_name = args.module_name
# check if string instance because module_name has default `True`
if isinstance(args.name, str) and isinstance(args.module_name, str):
print(
f"ValueError: Received both positional arg name={args.name} and named arg module_name={args.module_name}. Pass either one."
)
return

# merged the positional arg `name` with named arg `module_name` for backwards compatibility
module_name = args.module_name if isinstance(args.module_name, str) else args.name
base_builder = self.shell.user_ns[args.builder] if args.builder else driver.Builder()
inputs = self.shell.user_ns[args.inputs] if args.inputs else {}
overrides = self.shell.user_ns[args.overrides] if args.overrides else {}
Expand Down

0 comments on commit 22c0373

Please sign in to comment.