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

Export/import of extras: #2416

Merged
merged 5 commits into from
Feb 13, 2019
Merged

Export/import of extras: #2416

merged 5 commits into from
Feb 13, 2019

Conversation

yakutovicha
Copy link
Contributor

@yakutovicha yakutovicha commented Jan 23, 2019

fixes #1761

  1. Extras are now exported together with other data
  2. Extras are now fully imported if the corresponding node did not exist
  3. In case the imported node already exists in a database the following
    logic may be chosen to import the extras:
    • keep_existing (default): keep extras with different names (old and imported
      ones), keep old value in case of name collision
    • update_existing: -/-/-, keep new value in case of name collision
    • ask: -/-/-, ask what to do in case of the name collision
    • mirror: completely overwrite the extras by the imported ones
    • none: keep old extras

@coveralls
Copy link

coveralls commented Jan 23, 2019

Coverage Status

Coverage increased (+0.03%) to 69.738% when pulling 1571b3d on yakutovicha:provenance_redesign into b85ac3e on aiidateam:provenance_redesign.

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I proposed some changes. As an additional comment, if I understand correctly, the extras import mode only affects nodes that are already present in the database. Specifically the none option will not import any of the extras in the archive. But shouldn't there also be a general option to not import any extras, regardless of whether the node is already present in the database or not?

aiida/backends/djsite/db/models.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
aiida/orm/importexport.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
@yakutovicha
Copy link
Contributor Author

@sphuber

I wanted to discuss with you this "general option" to import extras. I see two ways:

  1. If --extras-import-mode is set to 'none' it will not import any extras (independently if the node is present already or not)
  2. Add another option, say --import-new-extras that will only affect the extras of a new nodes

But shouldn't there also be a general option to not import any extras, regardless of whether the node is already present in the database or not

I would prefer to not define one option that will affect both existing and new nodes, because in this way you can not, for example, import new extras for the existing nodes and do not import extras for the new nodes.

Of course, people may never need that, but I think if to add a new option it should allow to any combination of behavior with regard to the new and existing nodes.

@yakutovicha
Copy link
Contributor Author

Apart from that last issue, I've already implemented all your suggestions

@sphuber
Copy link
Contributor

sphuber commented Jan 31, 2019

I agree that we probably want to have a solution that allows the user to choose all possible options, so that would exclude the first one. I would be fine with adding an additional option that exclusively effects the import behavior of extras for new nodes. @giovannipizzi what do you think?

@yakutovicha
Copy link
Contributor Author

Also, for the moment all extras are exported. Let me know I should add yes/no option for the extras export.

@sphuber
Copy link
Contributor

sphuber commented Jan 31, 2019

I spoke to @giovannipizzi and he agrees that we should have all combinations available to (power) users. So we should have two flags, --extras-mode-new and --extras-mode-existing with sensible defaults. Since having to deal with two flags can be quite cumbersome, we should have a "compound" flag --extras-mode, that sets the values of these flags. This should be possible in click. Maybe for now this is too much work, but when we close this PR we should open an issue for v1.1.0.

So if you can change the name of the current flag and implement the second --extras-mode-new we should be good to go. Thanks!

@yakutovicha
Copy link
Contributor Author

@sphuber all python 2 tests failed because of the same error:

Warning, treated as error:
autodoc: failed to import module u'test_postgres' from module u'aiida.backends.tests.manage.external'; the following exception was raised:
cannot import name timezone
make: *** [default] Error 2

and this has nothing to do with my changes

@sphuber
Copy link
Contributor

sphuber commented Feb 4, 2019

Yeah there seems to be a problem with pgtest which calls somewhere from datetime import timezone as Timezone which started failing for some reason. There are other PR's with the same problem. I will take a look to see if I can figure out what is going on

@sphuber
Copy link
Contributor

sphuber commented Feb 4, 2019

Found the problem: the package pg8000 which is a dependency of pgtest just made a new release v1.13.0 in which they dropped python 2 support. This means their line from datetime import timezone which is only supported in py3 fails for our python 2 setup. The problem is really that they used a minor version release to drop support of py2 🤦‍♂️ I will make an issue for this and fix it. We will have to wait for @szoupanos PR to be merged anyway. So for now there is nothing you have to do. Unless you want to tests your PR then you can manually insert in the requirements pg8000<=1.12.4 and run again.

@sphuber
Copy link
Contributor

sphuber commented Feb 4, 2019

@yakutovicha I opened a PR to fix the problem, so once it is merged you can rebase so your tests will run again

@yakutovicha
Copy link
Contributor Author

thanks @sphuber, just merged your changes

aiida/orm/importexport.py Show resolved Hide resolved
aiida/orm/importexport.py Show resolved Hide resolved
aiida/orm/importexport.py Show resolved Hide resolved
fixes #1761

1) Extras are now exported together with other data
2) Extras are fully imported if the corresponding node did not exist
3) In case imported node already exists in a database the following
logic may be chosen to import the extras:
   - keep_existing (default): keep extras with different names (old and impoted
     ones), keep old value in case of name collision
   - update_existing: -/-/-, keep new value in case of name collision
   - ask: -/-/-, ask what to do in case of the name collision
   - mirror: completely overwrite the extras by the imported ones
   - none: keep old extras
1) two options: --extras-mode-new and --extras-mode-existing
2) skip hidden extra for codes and all extras starting with _aiida_
1) Except when it is not a string
2) Except when it is too short or too long
3) add some tests for those cases
4) Improve related error messages
@yakutovicha
Copy link
Contributor Author

I made the requested changes.

@sphuber and @szoupanos let me know if something else still needs to be done

@sphuber sphuber merged commit b1b34f6 into aiidateam:provenance_redesign Feb 13, 2019
@sphuber
Copy link
Contributor

sphuber commented Feb 13, 2019

Thanks a lot @yakutovicha great work

@sphuber sphuber mentioned this pull request Feb 13, 2019
@yakutovicha yakutovicha deleted the provenance_redesign branch January 6, 2020 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants