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

Added option: EMMObased = False in ontology.load() #262

Merged
merged 12 commits into from
Oct 22, 2021

Conversation

francescalb
Copy link
Collaborator

@francescalb francescalb commented Oct 20, 2021

Description:

Loading ontologies that do not load skos and rdfs-schema needs to be supported.

Type of change:

  • Bug fix.
  • New feature.
  • Documentation update.

Checklist:

This checklist can be used as a help for the reviewer.

  • Is the code easy to read and understand?
  • Are comments for humans to read, not computers to disregard?
  • Does a new feature has an accompanying new test (in the CI or unit testing schemes)?
  • Has the documentation been updated as necessary?
  • Does this close the issue?
  • Is the change limited to the issue?
  • Are errors handled for all outcomes?
  • Does the new feature provide new restrictions on dependencies, and if so is this documented?

Comments:

Loading mapping.ttl from dlite dehydrogenation example does not fail,
but not sure if it actually loads:
onto = get_ontology('mapping.ttl').load(EMMObased=False)
onto.search(label = "*") returns nothing.
@francescalb francescalb linked an issue Oct 20, 2021 that may be closed by this pull request
@francescalb
Copy link
Collaborator Author

@jesper-friis I suggest having an option for loading that is EMMObased=False, with True as default.
Alternatively populated DAFAULT_LABEL_ANNOTATIONS in some way if they are in the ontology.

I am opening this as a draft pull request so we can discuss.

@jesper-friis
Copy link
Collaborator

I like the idea of having an option about whether an ontologi is EMMO-based or not. Maybe we even can generalise it further? What about making an settings data class, that collects all settings in one place? We can then offer two predefine settings selectable via a "style" (do we have a better name) option; a plain default style for ontopy and a emmo-style for emmopy. Users then either modify one of the pre-defined styles for their needs or create their own style.

I valid question is whether it is worth the effort. I actually think it might be, both because I think it would easy to implement and because it could simplify the rest of the code by moving logics about default options to a dedicated module.

@francescalb
Copy link
Collaborator Author

That sounds like a good idea, but are there more styles you are thinking about?

DEFAULT_LABEL_ANNOTATIONS
name_policy='uuid' in sync_attributes

@jesper-friis
Copy link
Collaborator

For our current needs, I don't think we need more than the 'plain' and 'emmo' style. But if people from e.g. the OBO community wants to use ontopy, it could be convenient for them to define a 'obo' style.

Copy link
Collaborator

@jesper-friis jesper-friis left a comment

Choose a reason for hiding this comment

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

This looks good. I think the possible generalisation discussed in this PR should be a separate issue.

ontopy/ontology.py Outdated Show resolved Hide resolved
@francescalb
Copy link
Collaborator Author

Sure. I meant what more than DEFAULT_ANNOTATION_LABELS and name_policy should be included in the style?

@jesper-friis
Copy link
Collaborator

Sorry for the misunderstanding. Some candidates in Ontology:

  • the class attributes dir_preflabel, dir_label, dir_name and dir_imported
  • default arguments to load(): catalog_file, url_from_catalog
  • default argument to sync_python_names(): annotations
  • default argument to sync_python_reasoner(): reasoner
  • default argument to sync_attributes(): name_policy, name_prefix, class_docstring

In ontograph.py it would be great to factor out the _default_style class attribute. ontodoc.py has also a lot of style-related code that would be great to factor out.

I think the new style or settings module should support separate sections for the different modules.

@francescalb
Copy link
Collaborator Author

OK, I have added tests for this simplified solution for now and opene a new issue for the more extensive style preferences

@francescalb francescalb marked this pull request as ready for review October 21, 2021 11:57
@francescalb
Copy link
Collaborator Author

@CasperWA
Test in test_modules.py fails because of redirection error in emmo-repo, Emanuele has been contacted about this.

@CasperWA
Copy link
Collaborator

CasperWA commented Oct 21, 2021

@CasperWA Test in test_modules.py fails because of redirection error in emmo-repo, Emanuele has been contacted about this.

If you think it is okay to skip the tests until then, please do this (put a @pytest.mark.skip("this is a reason why this test is being skipped") as the decorator for the test functions that should be skipped).
Then add an issue to keep track of this so we can unskip it once the issue has been resolved.

In other words - one should never merge a PR that doesn't pass the CI.

Copy link
Collaborator

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Looks good.

I have some suggested changes, the only one I don't feel strongly about is the variable name change.

Concerning the test, please make a new function for this particular test instead of including it in another test function. The function name must start with test_ but that's it.

ontopy/ontology.py Outdated Show resolved Hide resolved
ontopy/ontology.py Outdated Show resolved Hide resolved
ontopy/ontology.py Show resolved Hide resolved
ontopy/ontology.py Show resolved Hide resolved
ontopy/ontology.py Show resolved Hide resolved
tests/test_load.py Show resolved Hide resolved
tests/test_load.py Show resolved Hide resolved
tests/test_load.py Outdated Show resolved Hide resolved
francescalb and others added 5 commits October 21, 2021 20:28
Move test for loading rdf and rdfs as non-EMMObased ontlogies to
separate ontlogiest
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
@francescalb
Copy link
Collaborator Author

francescalb commented Oct 21, 2021

@CasperWA Test in test_modules.py fails because of redirection error in emmo-repo, Emanuele has been contacted about this.

If you think it is okay to skip the tests until then, please do this (put a @pytest.mark.skip("this is a reason why this test is being skipped") as the decorator for the test functions that should be skipped). Then add an issue to keep track of this so we can unskip it once the issue has been resolved.

In other words - one should never merge a PR that doesn't pass the CI.

I was not thinking to merge it with a failing test. This is an old test and I expected the github-repo link to be fixed pretty fast as was the case :) My comment was to explain why I asked for a review even though there was an old test failing.

Copy link
Collaborator

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Rename the test_load() function in the test_load_rdf_rdfs.py file to test_load_rdfs() (or similar) and move it to the test_load.py file. There's no reason to create a new file.

@francescalb
Copy link
Collaborator Author

Rename the test_load() function in the test_load_rdf_rdfs.py file to test_load_rdfs() (or similar) and move it to the test_load.py file. There's no reason to create a new file.

Ah, so you want to have two tests in the same file. I understood that you wanted two separate files. Done now.

Copy link
Collaborator

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

It all looks good to me now :) Thanks @francescalb !

@francescalb francescalb merged commit 993e02f into master Oct 22, 2021
@CasperWA CasperWA deleted the flb/close-261-load_ontologies_without_skos branch March 2, 2022 16:25
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

Successfully merging this pull request may close these issues.

Loading ontologies that do not import skos fails
3 participants