Skip to content

accommodating mmif-python 1.6.0 #314

Closed

Description

@keighrim

Because

mmif-python 1.6.0 is being released (clamsproject/mmif-python#410) with the following changes that are relevant to clams-python;

  1. appTags is now a declared field of ViewMetadata
  2. MmifObject.set_additional_property() now stores a key that matches a declared attribute in that attribute, with a UserWarning, instead of keeping the same key in two places
  3. View.has_content() is added (true when the view has at least one annotation), and ViewsList.get_last_contentful_view() now returns the last view with content; empty views are skipped as well as error and warnings views
  4. Mmif.generate_capital_annotations() has a fixed duplicate check; it used to read the document ID of the first Annotation in a view and reuse it for all the others, so properties were written twice as soon as two or more documents got properties
  5. Mmif.get_annotations_of_labels() and video_document_helper.iter_timeframe_images() are promoted from the utl-tf app template

Done when

Proposal

  • ClamsApp.sign_view() writes appTags with view.metadata['appTags'] = ... instead of set_additional_property('appTags', ...) (
    if self.metadata.app_tags:
    view.metadata.set_additional_property('appTags', list(self.metadata.app_tags))
    ). With 1.6.0, the current call triggers the new UserWarning (2. above), and since annotate() records every warning raised during _annotate(), every app that declares app_tags would get an extra warnings view in its output. Item assignment goes to the declared field, so the tags are stored correctly either way; only the warning has to go.
  • ClamsApp.annotate() converts pending document properties into Annotations before deciding which views are empty, i.e., annotated.generate_capital_annotations() right after _annotate() returns. This fixes a bug introduced in adding consistent handling of "empty" views returned from apps #307; see "wrong attachment of capital Annotations" below. It relies on the fixed duplicate check (4. above), since serialize() converts the same pending properties once more.
  • the emptiness check in ClamsApp.annotate() (
    is_empty = lambda v: len(v.annotations) == 0 and not v.has_error() and not v.has_warnings()
    ) is written with mmif-python's definitions; not (v.has_content() or v.has_error() or v.has_warnings()), so the rule from handling of "empty" views #305 doesn't keep its own copy of what a "contentful" view is. Note that the error and warnings terms have to stay; an app can set an error or warnings on its own view, and such a view has no annotations but must not be deleted.
  • deprecate the utl-tf recipe of clams develop (https://github.com/clamsproject/clams-python/tree/085770e71d25bf2ed366447b5c9c55fb500ca8b1/clams/develop/templates/utl-tf) , since its functions now live in mmif-python (5. above); namely,
  • tests that call get_last_contentful_view() are checked against the new semantics (3. above); at the moment that's only test_error_handling (
    out_mmif_from_mmif.views.get_last_contentful_view(),
    out_mmif_from_str.views.get_last_contentful_view())
    )

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions