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

Code organisation in Django JSONB #2791

Closed
szoupanos opened this issue Apr 22, 2019 · 3 comments
Closed

Code organisation in Django JSONB #2791

szoupanos opened this issue Apr 22, 2019 · 3 comments
Assignees
Milestone

Comments

@szoupanos
Copy link
Contributor

We should check if the following tests are valid under DjangoJSONB

  • aiida.backends.djsite.db.subtests.test_query.TestQueryBuilderDjango
  • aiida.backends.djsite.db.subtests.test_nodes.TestNodeBasicDjango

Moreover, there is some code duplication in the following files related to EAV functionality, needed in migrations and migration tests. it is good to see how it can be avoided.

  • aiida/backends/djsite/db/migrations/init.py
  • aiida/backends/djsite/db/subtests/migrations/test_migrations_0034_attributes_extras_settings_json.py

Furthermore, the following QueryBuilder implementation files

  • aiida/orm/implementation/sqlalchemy/querybuilder.py
  • aiida/orm/implementation/django/querybuilder.py

have some common parts that are identical (e.g. get_filter_expr_from_attributes). We should see how we can merge them in a reasonable way. E.g. maybe the common functionality can now go to aiida/orm/implementation/querybuilder.py

With the work on Django JSONB, the import methods of AiiDA (for each backend) are very similar. The only difference is the way we create objects and we handle transactions (I hope). We should see if these two methods can now be unified in one.

@szoupanos szoupanos added this to the v1.1.0 milestone Apr 22, 2019
@szoupanos szoupanos self-assigned this Apr 22, 2019
@sphuber sphuber self-assigned this Jun 22, 2019
@sphuber
Copy link
Contributor

sphuber commented Jun 22, 2019

The two sub tests have been removed as they were no longer applicable. This functionality is now tested in backend independent way in aiida.backends.tests.orm.implementation.

Regarding the duplication of EAV functionality, I would leave it as it is. This code is there as a record of what it was at the time of the migration and as such should most likely remain static. In any case, hopefully in the near future we will reset the database schemas and we can get rid of all migration code including these files.

The QueryBuilder implementation duplication is still something worthwhile investigating, but I would say this is no longer a Django JSONB migration specific issue. If you agree, we close this issue and open one specifically for this code reorganization goal.

@sphuber
Copy link
Contributor

sphuber commented Jun 25, 2019

Most of the points have been addressed. The refactoring of the query builder implementation continues in #3082

@sphuber sphuber closed this as completed Jun 25, 2019
@szoupanos
Copy link
Contributor Author

Hello Seb. My recollection is what you wrote.
So if this is your opinion too, let's continue like this.

My main doubt was the tests that you removed - but I understand from your comment that you had a close look at them and they are no longer needed.

For the code duplication at the migration, I agree and I also agree for QB.

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

2 participants