-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add docs page containing table that maps typecodes to schema classes #2319
Add docs page containing table that maps typecodes to schema classes #2319
Conversation
|
Until someone opens up another PR in this repo, the newly-implemented page will be preview-able at https://microbiomedata.github.io/nmdc-schema/pr-preview/pr-2319/typecode-to-class-map/. |
This is a good improvement to the documentation and I am inclined to approve it. Question: what is the native sort order of the table? The sorting controls work for me, so it isn't a critical problem. I just couldn't figure out the order on my own. Request: please add some brief documentation about the differences between how this code determines the typecodes of classes, vs the code that implements https://api.microbiomedata.org/docs#/metadata/get_nmdc_schema_typecodes_nmdcschema_typecodes_get retrieves What are the advantages and disadvantages of both? Is there a plan for ensuring that the two tools stay in sync? |
Well, this certainly looks like I was imagining! I'm fine with sorting it in-page, or having it sort by typecode ascending on open. I definitely approve of this one, though I'll defer to Mark for the closing of the issue. Many thanks for being willing to make this! It's a nice snapshot of what we "do", where the rubber hits the road in terms of entities we track, at least from my point of view. |
Thanks, @turbomam and @SamuelPurvine.
I haven't done any explicit sorting in the code. As a result, the current order is based on the order in which a I will update the table to be sorted as follows (based upon the latest comment from @SamuelPurvine above):
It's a two-stage sorting algorithm because each "Typecode(s)" cell can contain multiple values, and those values have some order within the context of that cell. For example, if the values in a given "Typecode(s)" cell are "
I'd like to chat with you about this as I think there is something else that could be at play: storing the "typecode for newly-minted IDs" in its own slot in the class's definition, rather than storing it in a special place within a regex (I don't know whether the latter is documented anywhere other than in the minter's code and in meeting notes). Since we do currently have that "dual use" of that slot, I'd like the have a couple helper functions implemented in the Long-term, I want the "typecode for newly-minted IDs" to be stored separately in the schema, than being in a special place in the regex of "ID format that is legal for instances of this class." |
Also, I extracted the Note: We currently use the `pattern` property of the `id` slot for two different things: (a) to specify which
typecode we want ID generators (e.g., instances of the NMDC ID Minter) to use when generating new identifiers
(specifically, we want them to use only the _first_ typecode that occurs in the pattern), and (b) to specify
which typecodes we want ID validators (e.g., instance of the NMDC Runtime) to allow identifiers of instances
of that class to contain (they can contain _any_ one of the typecodes that occurs in the pattern). This
function returns the list for "use (b)." Eventually, we may specify the above two things using separate
schema elements. |
My plan is to update the Runtime to use the newly-implemented helper method named |
Since I have moved the typecode-extraction code into |
FYI:
Someone has opened up another PR in this repo, so the preview deployment of this PR no longer exists. |
I'm ready for this branch to be merged in. |
During today's (1/15/2025), @aclum mentioned that she wants this table to include a column that indicates which MongoDB collection instances of a given class can reside in (according to the schema). I'd prefer to merge this in without that column and then create a follow-on ticket about adding that column to the table. Are you OK with that sequence of events, @aclum? |
@eecavanna i agree that it makes sense to merge this in and add mongo collection as a new request. Let's get this merged so it can be part of the January release. |
I'll resolve those merge conflicts locally now and push up the resulting branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand the implementation of identifying future typecodes, but everything else looks great!
…de-to-schema-class-name # Conflicts: # Makefile # mkdocs.yml
Thanks, @turbomam. I'll try to explain that here (I think you are saying you don't understand the Here's that function, including its doctests: def get_typecode_for_future_ids(slot_pattern: str) -> Optional[str]:
r"""
Returns the typecode, if any, that schema authors want future values of the specified `id` field to contain.
:param slot_pattern: The value of the `pattern` property of the `id` slot definition
>>> get_typecode_for_future_ids("(nmdc):foo-...") is None
True
>>> get_typecode_for_future_ids("^(nmdc):foo-...")
'foo'
>>> get_typecode_for_future_ids("^(nmdc):(foo|bar)-...")
'foo'
>>> get_typecode_for_future_ids("^(nmdc):(foo|bar|baz)-...")
'foo'
"""
compatible_typecodes = get_compatible_typecodes(slot_pattern)
return compatible_typecodes[0] if len(compatible_typecodes) > 0 else None Given a regex pattern like the following...
...here's what this function does:
|
Here's the ticket in the Runtime repo where I am tracking the task of updating the Runtime to use the helper function that is now being exported from the |
Here's a link to the Runtime PR where I replaced its own "extract typecode from pattern" function with the one implemented in the |
On this branch, I implemented a new page of the schema docs—a page that contains a table that can be used to map a typecode to a schema class. I added a link to that page, to the sidebar navigation menu. The page gets generated dynamically during the documentation build process.
Here's what the page looks like on the website:
Highlights:
Fixes #2285