Skip to content

Conversation

@sdruskat
Copy link
Contributor

@sdruskat sdruskat commented Oct 2, 2025

This PR adds explanatory documentation of the public API.
It complements #432

@sdruskat sdruskat mentioned this pull request Oct 2, 2025
1 task
@sdruskat
Copy link
Contributor Author

@SKernchen Please review changes and approve as you see fit.
As warnings are treated as errors in the action workflow, and there are some outdated imports due to refactoring in progress, I suggest running poetry run taask docs-live locally to check.

@sdruskat sdruskat requested a review from SKernchen October 17, 2025 07:52
Copy link
Contributor

@SKernchen SKernchen left a comment

Choose a reason for hiding this comment

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

I really like the improvements. My suggestion is showing a more complex example. If we keep the short version, we should mention that "bar" is the expected name.


```{code-block} python
:caption: Value check and list comprehension
if ["bar" in email for email in data["author"][1]["email"]]:
Copy link
Contributor

@SKernchen SKernchen Oct 24, 2025

Choose a reason for hiding this comment

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

Suggested change
if ["bar" in email for email in data["author"][1]["email"]]:
if [data["author"][1]["name"][0].lower() in email for email in data["author"][1]["email"]]:

Copy link
Collaborator

Choose a reason for hiding this comment

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

A more general solution could be:

author = data["author"][0]
if all(any(name in email for name in author["name"]) for email in author["email"]):


#### Model instances in different types of plugin

You can extend `hermes` with plugins for three different commands: `harvest`, `curate`, `deposit`.
Copy link
Contributor

Choose a reason for hiding this comment

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

So "process plugins" and "post-process plugins" won't exist any more? This should (also) be mentioned in some architectural doc rather than in a side note here. As far as I can tell it is not mentioned anywhere else yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Made an issue for that #447 . In the parent issue it is also described.

Comment on lines +107 to +121
```{code-block} python
:caption: Injecting additional schemas
from hermes.model import SoftwareMetadata
# Contents served at https://bar.net/schema.jsonld:
# {
# "@context":
# {
# "baz": "https://schema.org/Thing"
# }
# }
data = SoftwareMetadata(extra_vocabs={"foo": "https://bar.net/schema.jsonld"})
data["foo:baz"] = ...
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit of a strange example because you're using a type as a predicate. You could use something like https://schema.org/name (/alternateName/description/image/...) instead.

data["name"] = "My Research Software" # A simple "Text"-type value
# → Simplified model representation : { "name": [ "My Research Software" ] }
# Cf. "Accessing data" below
data["author"] = {"name": "Foo"} # An object value that uses terms available in the defined context
Copy link
Contributor

Choose a reason for hiding this comment

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

All the foos, bars, and bazes can be quite confusing as it is never obvious what they are referring to. Could we use some more meaningful examples? "author" is a real codemeta field, so why not use a "real" author? Like Josiah Carberry, or Donald E. Knuth, or Margaret Hamilton.

Comment on lines +202 to +204
for i, author in enumerate(data["author"]):
if author["name"][0] in ["Foo", "Bar"]:
print(f"Author {i + 1} has expected name.")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use enumerate(..., start=1) instead of i + 1


```{code-block} python
:caption: Value check and list comprehension
if ["bar" in email for email in data["author"][1]["email"]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ["bar" in email for email in data["author"][1]["email"]]:
if all(["bar" in email for email in data["author"][1]["email"]]):

I think this is what you meant

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that is true. This line is also discussed in this comment.


The complex data structure of JSON-LD is internally constructed in the `hermes` data
model, and to make it possible to work with only the data that is important - the actual terms
and their values - the internal data model types provide a function `.to_python()`.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's all Python though 👀 Would .to_dict() be a better name?

Copy link
Collaborator

@notactuallyfinn notactuallyfinn Oct 24, 2025

Choose a reason for hiding this comment

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

I think .to_native() or .to_native_python() would be even better, since ld_dict is also a dict and this function also exists for ld_list.
But all suggestions do not mention that the structure is simplified in the process (similar, but not synonymous with compacting the expanded JSON-LD value).

@sdruskat
Copy link
Contributor Author

Thanks for all of your comments. I'll address them after my holidays.

@sdruskat sdruskat marked this pull request as draft October 26, 2025 16:20
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.

5 participants