Skip to content

Name assignment patterns for child collections #261

@wpbonelli

Description

@wpbonelli

When constructing a simulation bottom-up (cf #259) one may have already provided a name to packages or models when it comes time to attach them to a model or simulation, respectively. This makes the current dictionary syntax awkward as one needs to repeat the name

gwf = Gwf(
    name="my_flow_model",
    ...
)
sim = Simulation(
    name="my_sim",
    models={"my_flow_model": gwf_model},
    ...
)

Currently if the two provided names differ, the one given via dictionary syntax to the parent component overrides the one set via the child's initializer. I'm thinking we at least want to warn in this case, so the user knows which one is being used. But it would be more convenient to allow a list (and auto-assign a name if one was not given to the child)

sim = Simulation(
    name="my_sim",
    models=[gwf_model],
    ...
)

or even accept any of a single value, a list, or a dict, so you could do

sim = Simulation(
    name="my_sim",
    models=gwf_model,
    ...
)

While this could be seen as an enhancement I'm calling it a bug because as mentioned above, we at least need a warning on name override.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontendRelated to the user-facing APIrequirementCore requirement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions