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

Allow annotation stores to include/depend on other annotation stores (stand-off STAM JSON files) #29

Closed
2 tasks done
proycon opened this issue Jul 23, 2024 · 2 comments
Closed
2 tasks done
Assignees
Labels
enhancement New feature or request ready Implemented, pending release
Milestone

Comments

@proycon
Copy link
Collaborator

proycon commented Jul 23, 2024

Currently an annotation store in STAM JSON can reference annotation datasets
and resources in separate stand-off files. What is not yet possible, however,
is to reference annotations defined in other STAM JSON annotation stores.

This use-case was raised in #21 by @tenzin3, see the lead up discussion there.

In such a case, an annotation in store_a.store.stam.json makes reference (via
an annotation selector) to an annotation defined in store_b.store.stam.json.
That is currently not possible. I do think it is a fair use case and more
flexibility in using stand-off files fits nicely with STAM's stand-off
philosophy.

This issue proposes to expand the STAM model to allow this:

  • The @include mechanism in STAM JSON would be extended to allow including
    other annotation stores. In effect, an annotation store can then depend
    on on another by importing it, these includes are executed before loading any of its own annotations.
    Recursive includes would be allowed (allowing more complex dependency chains),
    but cyclic includes would be explicitly forbidden! Includes may (and are in fact encouraged to) reference the same
    stand-off resources and annotation data sets.

Possible syntax for this:

{
    "@type":"AnnotationStore",
    "@include": [ "store_b.stam.store.json", "store_c.stam.store.json" ],
    ...
}
  • On the implementation-side, when loaded into memory there is still always one
    AnnotationStore instance to work with at any given time. This would
    however serialize to multiple files. This requires some extra bookkeeping
    to be implemented, as for each annotation we need to know to what
    annotation store it should go. The implementation might define
    'substores' and keep map filenames to lists of annotation handles.
    This new bookkeeping would at the same time make splitting stores easier
    than it is in the currently implementation (where splitting is basically a fairly expensive deletion action).
    Merging and splitting becomes more reversible.
@proycon proycon self-assigned this Jul 23, 2024
@proycon proycon added the enhancement New feature or request label Jul 23, 2024
@proycon proycon added this to the v1.1 milestone Jul 23, 2024
proycon added a commit that referenced this issue Aug 23, 2024
proycon added a commit to annotation/stam-rust that referenced this issue Aug 28, 2024
proycon added a commit to annotation/stam-python that referenced this issue Aug 28, 2024
@proycon proycon added the ready Implemented, pending release label Aug 29, 2024
@proycon proycon closed this as completed Aug 29, 2024
@proycon
Copy link
Collaborator Author

proycon commented Aug 30, 2024

@tenzin3 @ngawangtrinley This has now been implemented (in stam-rust 0.15.0, stam-tools 0.8.0, stam-python 0.9.0). The @include mechanism is extended to allow including other annotation stores as dependencies. The STAM JSON specification here explains how this works.

The implementation should still be considered a bit experimental though, as it hasn't yet been thoroughly tested in real use cases like yours, so it's possible that some bugs may still surface or that some more API methods are desired.

When creating multiple annotation stores that have dependencies, it is recommended to first create the dependencies independently, and then later include them from the 'superstore' using this new method: https://stam-python.readthedocs.io/en/latest/autoapi/stam/index.html#stam.AnnotationStore.add_substore .

@tenzin3
Copy link

tenzin3 commented Sep 4, 2024

@proycon. Thank you for implementing this feature so quickly. We will test this out and get back to you if we are facing any issues .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready Implemented, pending release
Projects
None yet
Development

No branches or pull requests

2 participants