Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide option to add an item together with all its dependencies #306

Open
manuelma opened this issue Nov 9, 2023 · 5 comments
Open

Provide option to add an item together with all its dependencies #306

manuelma opened this issue Nov 9, 2023 · 5 comments
Assignees
Milestone

Comments

@manuelma
Copy link
Collaborator

manuelma commented Nov 9, 2023

The idea is e.g. when adding a parameter value for an entity or parameter definition that don't exist yet, the entity and parameter definition get optionally created - in other words, anything needed so the parameter value can exist.

So this should be controlled via an additional keyword argument for add_item and also for add_update_item.

At the moment, the ImportMapping class provides this functionality for some of the items (entities and entity groups) but not for all. After this change then, the ImportMapping should be using the new convenience developed.

@manuelma manuelma self-assigned this Nov 9, 2023
@jkiviluo jkiviluo added this to the v0.8.1 milestone Nov 21, 2023
@manuelma
Copy link
Collaborator Author

manuelma commented Nov 24, 2023

I found out that when importing scenario-alternatives, we import all necessary scenarios and alternatives. That has two problems in my opinion:

  • Importing dependencies should always be optional because of typos
  • We shouldn't import dependencies by default for some item types and not others.

So if nobody disagrees I will disable importing scenarios and alternatives automatically when importing scenario-alternatives. It will be controlled by a keyword argument or something like that. Any thoughts @jkiviluo @soininen ?

@jkiviluo
Copy link
Member

Can you clarify:

  • when importing just alternative, then only alternative will be imported. I think this is desired behaviour. Is it happening?
  • when importing scenarios, one cannot meaningfully import a scenario without importing dependent alternatives. So, if one or more of the dependent alternatives is missing, then we should either a) create the missing alternatives, b) raise an error.

In my view, that last one should be controlled by the user (to keep typos at bay using b). Is this what you were also thinking?

@manuelma
Copy link
Collaborator Author

manuelma commented Nov 24, 2023

when importing just alternative, then only alternative will be imported. I think this is desired behaviour. Is it happening?

Yes

when importing scenarios, one cannot meaningfully import a scenario without importing dependent alternatives. So, if one or more of the dependent alternatives is missing, then we should either a) create the missing alternatives, b) raise an error.

One can add a scenario without any alternatives (add_scenario_item). The scenario_alternative items are added later on via a separate method (add_scenario_alternative_item).

The same should be valid for import, otherwise it's just weird. You should import your scenario, alternative, and scenario_alternative items individually.

@jkiviluo
Copy link
Member

Right. I was just thinking of a scenario where one is copying from one DB to another. However, you probably mean that when one is programmatically creating scenarios, then one could make the scenario first and only then add the scenario_alternatives. So, yes, there should be an option to not import associated scenario-alternatives, when importing scenarios. And the default API behaviour should be the same as elsewhere (do not import dependents automatically). In the importer tool the default might be other way around (since it usually makes sense to get the alternatives with the scenario - the alternatives are what really form the scenario).

@soininen
Copy link
Collaborator

We should indeed be consistent i.e. not create non-existent alternatives when adding scenario-alternatives by default.

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

No branches or pull requests

3 participants