Skip to content

Make GConfiguration constructor args effective (factory/variation/runno)#12

Open
zhaozhiwen wants to merge 1 commit into
gemc:mainfrom
zhaozhiwen:fix/122-gconfiguration-args
Open

Make GConfiguration constructor args effective (factory/variation/runno)#12
zhaozhiwen wants to merge 1 commit into
gemc:mainfrom
zhaozhiwen:fix/122-gconfiguration-args

Conversation

@zhaozhiwen

Copy link
Copy Markdown
Collaborator

The argparse defaults for --factory/--variation/--run were truthy ("sqlite"/"default"/1), and __init__ resolved each as self.args.X if self.args.X else <ctor_arg>. Because the CLI value was always truthy (its default), the constructor fallback never fired: GConfiguration(exp, sys, factory="ascii", variation="run2", runno=5) silently produced sqlite/default/1 — programmatic configuration was impossible.

Set the argparse defaults to None so "not provided" is detectable, move the effective defaults onto the constructor parameters, and fall back with is not None. This keeps the documented CLI-over-constructor precedence while making constructor arguments actually work.

Validation: constructor args take effect with no CLI flags, bare defaults resolve to sqlite/default/1, and CLI flags still override the constructor (Python 3.12).

Fixes #6

The argparse defaults for --factory/--variation/--run were truthy
("sqlite"/"default"/1), and __init__ resolved each as
`self.args.X if self.args.X else <ctor_arg>`. Because the CLI value was
always truthy (its default), the constructor fallback never fired:
GConfiguration(exp, sys, factory="ascii", variation="run2", runno=5)
silently produced sqlite/default/1 — programmatic configuration was
impossible.

Set the argparse defaults to None so "not provided" is detectable, move
the effective defaults onto the constructor parameters (sqlite/default/1),
and fall back with `is not None`. This keeps the documented CLI-over-
constructor precedence while making constructor arguments actually work.

Verified: constructor args take effect with no CLI flags, bare defaults
resolve to sqlite/default/1, and CLI flags still override the constructor
(Python 3.12).

Fixes gemc#6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Medium] GConfiguration ignores constructor args; argparse defaults clobber factory/variation/runno

1 participant