Skip to content

Improve utilisation of ro-crate-py features - #22

Merged
elichad merged 4 commits into
mainfrom
13-improve-rocrate-usage
Oct 7, 2026
Merged

elichad merged 4 commits into
mainfrom
13-improve-rocrate-usage

Conversation

@faizollah

@faizollah faizollah commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses all three suggestions in the issue.

  1. Person helper — _person() now builds rocrate.model.Person instead of a ContextEntity with a hand-written "@type": "Person".

  2. append_to — root and entity properties (conformsTo, license, author, mentions, additionalProperty) are linked with append_to rather than direct assignment, so existing values are preserved. The instrument/object/result/metric lists now collect entities directly instead of hand-built {"@id": ...} dicts — the library converts them to references.

  3. add_action — the #fl-run CreateAction is built with crate.add_action(...), which sets the @type and takes instrument/object/result as arguments (its own empty-value guards replace the manual if checks).

Closes #13

faizollah and others added 3 commits September 7, 2026 13:59
Replace hand-built JSON-LD references with the library's own APIs:
- add people via rocrate.model.Person instead of a ContextEntity with a
  manual @type
- link root and entity properties with append_to, which preserves existing
  values instead of overwriting them
- build the CreateAction with crate.add_action, which sets the @type and
  takes instrument/object/result directly

Root author, conformsTo and license are now arrays rather than single
values, which is valid JSON-LD and is what append_to produces; three test
assertions and the committed example crate are updated to match.
Root conformsTo now lists the Process Run Crate profile alongside the FL
profile, with a Profile contextual entity for each as RO-Crate 1.2 requires.

Validating with rocrate-validator surfaced several defects, all fixed:
timestamps carried sub-second precision that failed ISO 8601 checks, the
model file had no encodingFormat, File entities had no contentSize, and
SoftwareApplication entities for the strategy and for dependencies outside
the known-frameworks map had no url. Version is now recorded as version
rather than softwareVersion, which the RO-Crate 1.2 profile requires.

The crate validates against ro-crate-1.2 at REQUIRED severity with no
issues. The example crate is regenerated to match.
Declare conformance to Process Run Crate and fix validation issues

@stain stain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggest fixing the perma-ids

Comment thread examples/quickstart-pytorch/ro-crate-metadata.json
Comment thread examples/quickstart-pytorch/ro-crate-metadata.json Outdated
Comment thread flwrcrate/crate_builder.py Outdated
Address review on #22: SPDX license identifiers now use the form from
SPDX's RDF serialisations (http://spdx.org/licenses/MIT) rather than the
.html page, in docs, examples, tests and the missing-license warning.
Declare Process Run Crate 0.6, the current release.

author_ref = None
if author:
author_ref = _person(crate, author, "#author")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thought on this fallback id - do we ensure that duplicate ids don't get created if multiple authors are added? (e.g. does it automatically become #author-2, #author-3 etc)

@elichad elichad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good now!

@elichad
elichad merged commit b95179b into main Oct 7, 2026
9 checks passed
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.

Improve utilisation of ro-crate-py (rocrate) features

3 participants