From 691d3c33134a1932d9957c2acaea8685872c2593 Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Thu, 4 Jan 2024 08:38:11 +0100 Subject: [PATCH] New `git` ontology component with new `GitTracked` mixin This aims to be the foundation for data models of Git-tracked content. The availability of a globally unique identifier in this context allows for great flexibility in model specification. At the same time, introducing a `identifier:true` property in a class hierarchy can be problematic, because turning an existing base-class property into an identifier in a derived class does not seem to be possible (https://github.com/psychoinformatics-de/datalad-concepts/issues/30). This approach uses a dedicated mixin class for this purpose. The identifier itself uses the `meta_id` slot, and is intentionally distinct from the `gitsha` property. The identifier is composed from the `gitsha` by adding a corresponding namespace prefix. This keeps the identifier property uniform across unrelated classes, while also preserving the semantics of the identifier type. --- src/linkml/git-provenance-schema.yaml | 30 ++------------------ src/linkml/git.yaml | 41 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 src/linkml/git.yaml diff --git a/src/linkml/git-provenance-schema.yaml b/src/linkml/git-provenance-schema.yaml index 625abbe..5c585d4 100644 --- a/src/linkml/git-provenance-schema.yaml +++ b/src/linkml/git-provenance-schema.yaml @@ -14,6 +14,7 @@ prefixes: linkml: https://w3id.org/linkml/ prov: http://www.w3.org/ns/prov# imports: + - git - labeling - meta_utils - provenance @@ -21,13 +22,6 @@ imports: default_prefix: dlco -slots: - gitsha: - description: >- - SHA1 identifier of a Git object. - range: SHA1 - - classes: # TODO orthogonalize/consolidate with datalad-dataset:Commit # the relevant class is not this one, but the @@ -37,31 +31,11 @@ classes: A revision or an individual change in a Git repository. mixins: - CommitProvenance - slots: - - gitsha - - meta_id + - GitTracked slot_usage: gitsha: description: >- SHA1 identifier of the commit object. - meta_id: - pattern: "^gitsha:[0-9a-f]{40}$" - description: >- - SHA1 identifier written as a CURIE in an explicit - `gitsha:` namespace. - - unique_keys: - gitsha: - description: >- - A commit's GITSHA is a globally unique, content-based identifier - of that commit. - notes: - - The `gitsha` slot could have been labled to be the one identifier - of a Commit-type object. However, we use `meta_type` for - consistency and use its CURIE-format to assign an explicit - namespace. - unique_key_slots: - - gitsha CommitProvenance: mixin: true diff --git a/src/linkml/git.yaml b/src/linkml/git.yaml new file mode 100644 index 0000000..ae568ab --- /dev/null +++ b/src/linkml/git.yaml @@ -0,0 +1,41 @@ +id: https://concepts.datalad.org/git +name: git +title: Git concepts +description: > + TODO +prefixes: + gitsha: https://concepts.datalad.org/namespace/gitsha/ + dlco: https://concepts.datalad.org/ontology/ +imports: + - meta_utils + - types +default_prefix: dlco + + +slots: + gitsha: + description: >- + SHA1 identifier of a Git object. + range: SHA1 + + +classes: + GitTracked: + mixin: true + description: >- + Mixin class for any ressource tracked by Git, thereby having a unique + `gitsha` identifier. + slots: + - gitsha + - meta_id + slot_usage: + meta_id: + description: >- + SHA1 based identifier in the form of a CURIE with an explicit + `gitsha:` namespace prefix. + equals_expression: "gitsha:{gitsha}" + pattern: "^gitsha:[0-9a-f]{40}$" + comments: + - Because there can only be a single main `identifier`, this mixin + cannot be used on classes that already have or inherited another + property declared as `identifier:true`.