BlueBrain / nexus-forge

Building and Using Knowledge Graphs made easy
https://nexus-forge.readthedocs.io
GNU Lesser General Public License v3.0
38 stars 19 forks source link

Refactor services #348

Closed ssssarah closed 8 months ago

ssssarah commented 10 months ago

Services are being initialised in Resolver, Store and Model but there was no typing and abstraction that defined what these services were. In this PR, there some reorganising of where the services are, what classes they extend, and which classes can be used as a service for the Resolver, Store and Model

codecov-commenter commented 10 months ago

Codecov Report

Attention: 115 lines in your changes are missing coverage. Please review.

Comparison is base (cece1ce) 73.45% compared to head (4808f76) 73.52%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #348 +/- ## ========================================== + Coverage 73.45% 73.52% +0.07% ========================================== Files 91 91 Lines 5831 5873 +42 ========================================== + Hits 4283 4318 +35 - Misses 1548 1555 +7 ``` | [Flag](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) | `73.52% <51.06%> (+0.07%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) | Coverage Δ | | |---|---|---| | [...lizations/models/services/rdf\_directory\_service.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9zcGVjaWFsaXphdGlvbnMvbW9kZWxzL3NlcnZpY2VzL3JkZl9kaXJlY3Rvcnlfc2VydmljZS5weQ==) | `92.00% <100.00%> (ø)` | | | [...rge/specializations/models/services/rdf\_service.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9zcGVjaWFsaXphdGlvbnMvbW9kZWxzL3NlcnZpY2VzL3JkZl9zZXJ2aWNlLnB5) | `87.42% <100.00%> (ø)` | | | [...ecializations/models/services/rdf\_store\_service.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9zcGVjaWFsaXphdGlvbnMvbW9kZWxzL3NlcnZpY2VzL3JkZl9zdG9yZV9zZXJ2aWNlLnB5) | `20.75% <100.00%> (ø)` | | | [...ializations/stores/services/nexus\_store\_service.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9zcGVjaWFsaXphdGlvbnMvc3RvcmVzL3NlcnZpY2VzL25leHVzX3N0b3JlX3NlcnZpY2UucHk=) | `55.51% <100.00%> (ø)` | | | [...sts/specializations/stores/test\_bluebrain\_nexus.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-dGVzdHMvc3BlY2lhbGl6YXRpb25zL3N0b3Jlcy90ZXN0X2JsdWVicmFpbl9uZXh1cy5weQ==) | `93.86% <100.00%> (ø)` | | | [kgforge/core/commons/es\_query\_builder.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9jb3JlL2NvbW1vbnMvZXNfcXVlcnlfYnVpbGRlci5weQ==) | `98.41% <0.00%> (ø)` | | | [.../resolvers/entity\_linking/entity\_linker\_elastic.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9zcGVjaWFsaXphdGlvbnMvcmVzb2x2ZXJzL2VudGl0eV9saW5raW5nL2VudGl0eV9saW5rZXJfZWxhc3RpYy5weQ==) | `62.06% <0.00%> (ø)` | | | [kgforge/core/archetypes/resolver.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9jb3JlL2FyY2hldHlwZXMvcmVzb2x2ZXIucHk=) | `65.44% <77.77%> (+1.04%)` | :arrow_up: | | [kgforge/core/commons/execution.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9jb3JlL2NvbW1vbnMvZXhlY3V0aW9uLnB5) | `67.74% <33.33%> (ø)` | | | [kgforge/specializations/models/demo\_model.py](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#diff-a2dmb3JnZS9zcGVjaWFsaXphdGlvbnMvbW9kZWxzL2RlbW9fbW9kZWwucHk=) | `67.03% <71.42%> (-0.03%)` | :arrow_down: | | ... and [10 more](https://app.codecov.io/gh/BlueBrain/nexus-forge/pull/348?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

crisely09 commented 10 months ago

This is not a bad idea, but now that we are looking into the services, maybe we also avoid initializing the same store/service multiple times when creating a forge instance, what do you think?

ssssarah commented 10 months ago

Agreed but I see this as a first step in improving readability, I'm not changing much in terms of functionality and features. I think it would help to get a clearer picture of the dependencies of models and resolvers on their own store instances