diff --git a/.copier-answers.yml b/.copier-answers.yml index 40679914..09e84e2e 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,7 @@ _commit: v0.4.1 _src_path: https://github.com/linkml/linkml-project-copier add_example: false -copyright_year: '2025' +copyright_year: "2025" email: robert.carroll@vumc.org full_name: Robert Carroll gh_action_docs_preview: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3641b7a6..c65351b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,13 @@ ---- # https://pre-commit.com/ + +#exclude: "^(project/|generated/|target/|docs/|src/linkml/schema/submodules/|src/common_access_model/datamodel/|tests/)" +exclude: "^(project|src/common_access_model/datamodel/|tests/)" repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: - id: check-toml - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace - args: [--markdown-linebreak-ext=md] - repo: https://github.com/adrienverge/yamllint.git rev: v1.37.0 @@ -16,12 +15,19 @@ repos: - id: yamllint args: [-c=.yamllint.yaml] - - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 hooks: - - id: codespell - additional_dependencies: - - tomli + - id: prettier + types_or: [yaml] + language_version: "20.11.0" + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] - repo: https://github.com/crate-ci/typos rev: v1.31.1 @@ -29,17 +35,13 @@ repos: - id: typos - repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.11.3 + rev: v0.16.3 # Upgraded version hooks: - # Run the linter. - - id: ruff + - id: ruff-check # Works perfectly here args: [--fix, --exit-non-zero-on-fix] - # Run the formatter. - id: ruff-format - repo: https://github.com/astral-sh/uv-pre-commit - # uv version. rev: 0.6.12 hooks: - id: uv-lock diff --git a/.yamllint.yaml b/.yamllint.yaml index f44a825d..7a956cf7 100644 --- a/.yamllint.yaml +++ b/.yamllint.yaml @@ -3,10 +3,10 @@ extends: default rules: - document-start: disable # Don't check if document has a start marker (---). + document-start: disable # Don't check if document has a start marker (---). line-length: max: 80 level: warning allow-non-breakable-words: true allow-non-breakable-inline-mappings: true - new-lines: disable # Don't check for type of new line characters. + new-lines: disable # Don't check for type of new line characters. diff --git a/COLLABORATORS.md b/COLLABORATORS.md new file mode 100644 index 00000000..2c653e2e --- /dev/null +++ b/COLLABORATORS.md @@ -0,0 +1,155 @@ +## Welcome to the Common Access Model 🚀 + +This repository represents the core model, Common Access Model (CAM). In order +to allow downstream models to extend a common set of classes and their +properties, those models should adhere to use this model as a Git submodule. + +## Key Integration Guidelines + +All changes to this model should be made with the understanding that those +changes are completely valid for all or many of the downstream models. Those +changes should be made directly within this repository and not as changes to the +versions from the submodules themselves. + +Please see the following notes when integrating this model as a submodule within +one of the downtream modules: + +- Do Not Modify the Submodule from within this repository: All foundational + classes, slots, and enums live in the core submodule. Any program-specific + customizations must happen strictly in your downstream files. +- Leverage Imports: At this time, the current model imports the + common_access_model.yaml directly within the main model definition. +- Extend via Inheritance: Use the is_a or mixins keys to create program-specific + subclasses that inherit core slots while allowing you to add local attributes. +- Refine via Slot Usage: If you need to restrict or change the behavior of an + inherited core slot just for your program's classes, use the slot_usage + feature. + +## Getting Started + +If you aren't already familiar with working with submodules, there are just a +couple of key takeaways to keep in mind: + +- The submodule has been pinned to a specific git commit hash to avoid + unexpected changes the CAM creeping into downstream model interfering with + local builds, CI/CD scripts, etc. +- The submodule itself should only be updated by deliberate action with the + expectation that downstream model changes may be required to reflect incoming + updates. + +### Initializing the submodule + +Before you can actually compile the model on a new machine, you'll need to pull +the submodule's content down. A convenient just recipe has been created for +exactly that: + +```bash +just init-submodule +``` + +or, if you prefer to do it directly yourself: + +```bash +git submodule update --init --recursive +# make sure nothing is broken +just lint && just test +``` + +Subsequent calls can drop the init if you know for a fact that no other +submodules have been added. The just recipe does call the linter and runs the +linkml test as a subsequent dependency, in case there are upstream changes that +invalidate the downstream model. + +### Updating the pinned hash + +Once it has been decided that it is time to update the CAM to use the latest +version, the maintainer should run the following commands to fetch, test and +lock the new version into the downstream model's main. + +```bash +# Navigate into the submodule directory +cd src/kf_access_model/schema/common_access_model + +# Fetch and check out the desired remote target (e.g., main branch) +git fetch origin +git checkout origin/main + +# Move back to the repository root +cd - + +# Run linter and tests +just lint && just test + + +# Commit the new submodule hash pointer to this repository +git add src/kf_access_model/schema/common_access_model +git commit -m "chore: update common_access_model submodule to latest hash" +``` + +## Release Artifacts + +There are a number of artifacts which are used by various scripts including the +dbt utilities which are built via github actions during release. To trigger the +build, create releases linked to a semantic version preceded with a v (i.e. +v1.0.1). + +These artifacts include: + +- SQL Alchemy model +- dbt model yml file +- SQL Schema +- data dictionary conformant to the current FTD spec +- enumerations csv file extracted from all of the permissible values + +The last two are used by this group's dbt utilities tooling. The SQL Alchemy +model is used by a handful of other scripts. + +## Beautification + +### Code Quality & Formatting with pre-commit + +We use `pre-commit` to catch minor issues automatically before your changes +reach code review. This saves you time by automating formatting and linting +tasks, allowing code reviews to focus strictly on functionality and logic rather +than style choices. + +The hooks automatically run the following optimizations when you execute a +`git commit`: + +- **Formatting:** Standardizes Python code via **Ruff** and YAML configurations + via **Prettier** (matching the default styling behavior of editors like Zed). +- **Linting:** Analyzes code patterns and auto-fixes formatting anomalies on the + fly. +- **Checks:** Verifies structural syntax sanity for TOML/YAML layouts, removes + trailing whitespace, and forces trailing newlines. + +#### Getting Started (First-Time Setup) + +If you are setting up the repository for the first time, you don't even need to +install `pre-commit` globally on your system. You can handle everything through +**`uv`**: + +1. **Register the Git hook scripts** inside the local `.git/` directory using + `uv run`: + ```bash + uv run pre-commit install + ``` + +--- + +#### Subsequent Uses & Everyday Workflow + +Once registered, the tool seamlessly hooks into your normal Git workflow without +any manual intervention: + +- **Automatic Execution:** Every time you run `git commit`, the hooks + automatically run against your _staged changes_. `uv` will transparently + manage the tool environments in the background. +- **If a hook modifies a file (or fails):** The commit is safely aborted so you + can inspect the adjustments. Simply stage the updated files (`git add .`) and + run your `git commit` command again. +- **Manual Repository Check:** If you ever want to force formatting across the + entire repository manually without creating a commit, run: + ```bash + uv run pre-commit run --all-files + ``` diff --git a/config.yaml b/config.yaml index c37997f7..27e95fa4 100644 --- a/config.yaml +++ b/config.yaml @@ -60,5 +60,4 @@ generator_args: typescript: mergeimports: true metadata: true - ... diff --git a/mkdocs.yml b/mkdocs.yml index 3dc9c95b..1bb8c4cb 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -25,7 +25,7 @@ watch: - src/common_access_model/schema nav: -# - Home: index.md + # - Home: index.md - Schema: elements/index.md - ER Diagram: elements/erdiagram.md - dbt: dbt_artifacts.md diff --git a/src/common_access_model/_version.py b/src/common_access_model/_version.py index 786f3aaf..e2cfd55c 100644 --- a/src/common_access_model/_version.py +++ b/src/common_access_model/_version.py @@ -1,4 +1,4 @@ -from importlib.metadata import version, PackageNotFoundError +from importlib.metadata import PackageNotFoundError, version try: __version__ = version(__name__) diff --git a/src/common_access_model/datamodel/__init__.py b/src/common_access_model/datamodel/__init__.py index 7a6f89fa..616a5d08 100644 --- a/src/common_access_model/datamodel/__init__.py +++ b/src/common_access_model/datamodel/__init__.py @@ -1,4 +1,5 @@ from pathlib import Path + from .common_access_model import * THIS_PATH = Path(__file__).parent diff --git a/src/common_access_model/schema/common_access_model.yaml b/src/common_access_model/schema/common_access_model.yaml index 2134a4db..f0d267a0 100644 --- a/src/common_access_model/schema/common_access_model.yaml +++ b/src/common_access_model/schema/common_access_model.yaml @@ -117,7 +117,7 @@ types: base: str description: Dewrangle di global ID. For FHIR Diagnostic Report Resources. -# To be created + # To be created fmGlobalID: uri: xsd:string base: str @@ -131,7 +131,6 @@ types: base: str description: Dewrangle __ global ID. For FHIR MedicationStatement Resources. - classes: Any: class_uri: linkml:Any @@ -140,21 +139,21 @@ classes: title: Record abstract: true slots: - - external_id - - access_policy_id - - study_id + - external_id + - access_policy_id + - study_id AccessPolicy: title: Access Policy description: The access policy that describes the controls around use of data slots: - - access_policy_id - - data_use_accession - - data_use_permission - - data_use_modifier - - disease_limitation - - access_description - - website + - access_policy_id + - data_use_accession + - data_use_permission + - data_use_modifier + - disease_limitation + - access_description + - website slot_usage: access_policy_id: range: coGlobalID @@ -163,25 +162,26 @@ classes: Study: title: Research Study description: Study Metadata - is_a: Record + mixins: + - Record slots: - #TODO: Split out core Study items and additional study metadata? + #TODO: Split out core Study items and additional study metadata? #- study_id Inherits study_id from Record now. - - parent_study - - study_title - - study_code - - study_short_name - - program - - funding_source - - principal_investigator - - contact - - study_description - - website + - parent_study + - study_title + - study_code + - study_short_name + - program + - funding_source + - principal_investigator + - contact + - study_description + - website # - dbgap : Should we call this out specifically or just use an external id? - - publication - - acknowledgments - - citation_statement - - do_id + - publication + - acknowledgments + - citation_statement + - do_id slot_usage: study_id: range: sdGlobalID @@ -189,9 +189,9 @@ classes: identifier: true StudyMetadata: title: Study Metadata - description: Additional features about studies that may not apply to all - studies - is_a: Record + description: Additional features about studies that may not apply to all studies + mixins: + - Record slots: - study_id - participant_lifespan_stage @@ -216,9 +216,9 @@ classes: VirtualBiorepository: title: Virtual BioRepository (VBR) - description: An organization that can provide access to specimen for further - analysis. - is_a: Record + description: An organization that can provide access to specimen for further analysis. + mixins: + - Record slots: - vbr_id - name @@ -234,9 +234,9 @@ classes: DOI: title: Digital Object Identifier (DOI) - description: A DOI is a permanent reference with metadata about a digital - object. - is_a: Record + description: A DOI is a permanent reference with metadata about a digital object. + mixins: + - Record slots: - do_id - bibliographic_reference @@ -247,9 +247,9 @@ classes: identifier: true Investigator: title: Investigator - description: An individual who made contributions to the collection, - analysis, or sharing of data. - is_a: Record + description: An individual who made contributions to the collection, analysis, or sharing of data. + mixins: + - Record slots: - name - institution @@ -259,17 +259,20 @@ classes: Publication: title: Publication description: Information about a specific publication. - is_a: Record + mixins: + - Record #Could add more here slots: - bibliographic_reference - website Subject: title: Subject - description: This entity is the subject about which data or references are - recorded. This includes the idea of a human participant in a study, a cell - line, an animal model, or any other similar entity. - is_a: Record + description: + This entity is the subject about which data or references are recorded. + This includes the idea of a human participant in a study, a cell line, an animal model, + or any other similar entity. + mixins: + - Record slots: - subject_id - subject_type @@ -282,30 +285,31 @@ classes: Demographics: title: Demographics description: Basic participant demographics summary - is_a: Record + mixins: + - Record slots: - - subject_id - - sex - - race - - ethnicity - - age_at_last_vital_status - - vital_status - - age_at_first_engagement + - subject_id + - sex + - race + - ethnicity + - age_at_last_vital_status + - vital_status + - age_at_first_engagement slot_usage: subject_id: required: true identifier: true Family: title: Family - description: A group of individuals of some relation who are grouped - together in a study. - is_a: Record + description: A group of individuals of some relation who are grouped together in a study. + mixins: + - Record slots: - - family_id - - family_type - - family_description - - consanguinity - - family_study_focus + - family_id + - family_type + - family_description + - consanguinity + - family_study_focus slot_usage: family_id: range: grGlobalID @@ -314,14 +318,15 @@ classes: FamilyRelationship: title: Family Member Relationship description: A relationship between two Subjects. Directed as follows - - is_a: Record + + + mixins: + - Record slots: - - family_relationship_id - - family_member_id - - relation - - subject_id + - family_relationship_id + - family_member_id + - relation + - subject_id slot_usage: family_relationship_id: range: fmGlobalID @@ -332,9 +337,9 @@ classes: description: The family member Subject who is the relationship "object". FamilyMembership: title: Family Membership - description: Designates a Subject as a member of a family with a specified - role. - is_a: Record + description: Designates a Subject as a member of a family with a specified role. + mixins: + - Record slots: - family_membership_id - family_id @@ -351,9 +356,9 @@ classes: required: true SubjectAssertion: title: Subject Assertion - description: Assertion about a particular Subject. May include Conditions, - Measurements, etc. - is_a: Record + description: Assertion about a particular Subject. May include Conditions, Measurements, etc. + mixins: + - Record slots: - assertion_id - subject_id @@ -391,19 +396,19 @@ classes: identifier: true Sample: title: Sample - description: A functionally equivalent specimen taken from a participant or - processed from such a sample. - is_a: Record + description: A functionally equivalent specimen taken from a participant or processed from such a sample. + mixins: + - Record slots: - - sample_id - - biospecimen_collection_id - - parent_sample_id - - sample_type - - processing - - availablity_status - - storage_method - - quantity_number - - quantity_unit + - sample_id + - biospecimen_collection_id + - parent_sample_id + - sample_type + - processing + - availability_status + - storage_method + - quantity_number + - quantity_unit slot_usage: sample_id: range: bsGlobalID @@ -414,17 +419,17 @@ classes: generated. BiospecimenCollection: title: BiospecimenCollection - description: A biospecimen collection event which yields one or more - Samples. - is_a: Record + description: A biospecimen collection event which yields one or more Samples. + mixins: + - Record slots: - - biospecimen_collection_id - - age_at_collection - - method - - site - - spatial_qualifier - - laterality - - encounter_id + - biospecimen_collection_id + - age_at_collection + - method + - site + - spatial_qualifier + - laterality + - encounter_id slot_usage: biospecimen_collection_id: range: string @@ -432,17 +437,17 @@ classes: identifier: true Aliquot: title: Aliquot - description: A specific tube or amount of a biospecimen associated with a - Sample. - is_a: Record + description: A specific tube or amount of a biospecimen associated with a Sample. + mixins: + - Record slots: - - aliquot_id - - sample_id - - availablity_status - - quantity_number - - quantity_unit - - concentration_number - - concentration_unit + - aliquot_id + - sample_id + - availability_status + - quantity_number + - quantity_unit + - concentration_number + - concentration_unit slot_usage: aliquot_id: range: string @@ -450,9 +455,10 @@ classes: identifier: true Encounter: title: Participant Encounter - description: An event at which data was collected about a participant, an - intervention was made, or information about a participant was recorded. - is_a: Record + description: An event at which data was collected about a participant, + an intervention was made, or information about a participant was recorded. + mixins: + - Record slots: - encounter_id - subject_id @@ -471,7 +477,8 @@ classes: or information about a participant was recorded. This may be something planned by a study or a type of data collection. #TODO: These are metadata and may not need the same Record basis. - is_a: Record + mixins: + - Record slots: - encounter_definition_id - name @@ -489,11 +496,12 @@ classes: description: A definition of an activity in this study, eg, a biospecimen collection, assay, intervention, survey, or assessment. #TODO: These are metadata and may not need the same Record basis. - is_a: Record + mixins: + - Record slots: - - activity_definition_id - - name - - description + - activity_definition_id + - name + - description #TODO: Probably want an "expected data generated" slot, eg, #observation definitions or dd refs slot_usage: @@ -504,24 +512,25 @@ classes: File: title: File description: File - is_a: Record + mixins: + - Record slots: - - file_id - - subject_id - - sample_id - - filename - - format - - file_extension - - data_category - - data_type - - format - - size - - internal_uri #I'm keeping this for now, but it likely should not be here - - release_uri - - drs_uri - - storage_class #Taking out the autoclass part as it can change dynamically - - hash - - availability + - file_id + - subject_id + - sample_id + - filename + - format + - file_extension + - data_category + - data_type + - format + - size + - internal_uri #I'm keeping this for now, but it likely should not be here + - release_uri + - drs_uri + - storage_class #Taking out the autoclass part as it can change dynamically + - hash + - availability slot_usage: file_id: range: drGlobalID @@ -536,23 +545,23 @@ classes: title: File Hash description: Type and value of a file content hash. slots: - - hash_type - - hash_value + - hash_type + - hash_value Assay: title: Assay - description: A specific assay that was performed on given subject(s) or - sample(s). - is_a: Record + description: A specific assay that was performed on given subject(s) or sample(s). + mixins: + - Record slots: - - assay_id - - subject_id - - sample_id - - file_id - - assay_type + - assay_id + - subject_id + - sample_id + - file_id + - assay_type #Could set this up as an assay definition- not sure if we need a more specific entity - - assay_source - - activity_definition_id + - assay_source + - activity_definition_id slot_usage: assay_id: @@ -568,7 +577,6 @@ classes: assay_type: required: true - Dataset: title: Dataset description: Set of files grouped together for release. @@ -591,7 +599,6 @@ classes: multivalued: true description: The list of files comprising this dataset. - slots: study_id: title: Study ID @@ -600,13 +607,13 @@ slots: multivalued: false access_policy_id: title: Access Policy ID - description: Global identifier for the access policy that applies to this - row of data. + description: Global identifier for the access policy that applies to + this row of data. range: AccessPolicy data_use_accession: title: Data Use Accession - description: Accession used to provision access to the record, eg, a dbGaP - phsID. + description: Accession used to provision access to the record, eg, + a dbGaP phsID. range: uriorcurie data_use_permission: title: Data Use Permission @@ -619,8 +626,8 @@ slots: range: EnumDataUseModifier disease_limitation: title: Data Use Disease Limitation - description: If the access is limited to a specific disease purpose, it is - specified here. + description: If the access is limited to a specific disease purpose, + it is specified here. range: string access_description: title: Access Description @@ -643,11 +650,10 @@ slots: multivalued: false external_id: title: External Identifiers - description: Other identifiers for this entity, eg, from the submitting - study or in systems like dbGaP - required: false - range: uriorcurie - multivalued: true + description: Other identifiers for this entity, eg, from the submitting study or in systems like dbGaP + required: false + range: uriorcurie + multivalued: true parent_study: title: Parent Study description: The parent study for this study, if it is a nested study. @@ -798,13 +804,11 @@ slots: range: string citation_statement: title: Citation Statement - description: Statement that secondary data users should use to acknowledge - use of this study or dataset. E.g., "The results analyzed and here are based in whole or in part upon data generated by the - INCLUDE (INvestigation of Co-occurring conditions across the Lifespan to - Understand Down syndromE) Project , and were accessed from the INCLUDE Data Hub and ." + description: + Statement that secondary data users should use to acknowledge use of this study or dataset. E.g., + "The results analyzed and here are based in whole or in part upon data generated by the INCLUDE + (INvestigation of Co-occurring conditions across the Lifespan to Understand Down syndromeE) Project , and were accessed from the INCLUDE Data Hub and ." range: string bibliographic_reference: title: Bibiliographic Reference @@ -853,9 +857,9 @@ slots: age_at_first_engagement: #Should this just be a reference out to an encounter? title: Age at First Participant Engagement - description: Age in days of Participant at first recorded study event - (enrollment, visit, observation, sample collection, survey completion, - etc.). Age at enrollment is preferred, if available. + description: + Age in days of Participant at first recorded study event (enrollment, visit, observation, + sample collection, survey completion, etc.). Age at enrollment is preferred, if available. range: integer unit: ucum_code: d @@ -904,9 +908,9 @@ slots: range: Subject inlined: false relation: - description: Code definting the relationship predicate. Relationship of the - "Family Member" to the "Subject", eg, mother of. Ideally uses KIN - ontology. + description: + Code definting the relationship predicate. Relationship of the "Family Member" + to the "Subject", eg, mother of. Ideally uses KIN ontology. required: true range: Concept any_of: @@ -917,8 +921,7 @@ slots: description: ID for the Family Relationship range: FamilyMembership family_role: - description: The "role" of this individual in this family. Could include - terms like "proband", "mother", etc. + description: The "role" of this individual in this family. Could include terms like "proband", "mother", etc. range: uriorcurie any_of: - range: uriorcurie @@ -939,8 +942,9 @@ slots: ucum_code: d age_at_event: title: Age at event - description: The age in days of the Subject at the time point which the - assertion describes, eg, age of onset or when a measurement was performed. + description: + The age in days of the Subject at the time point which the assertion describes, + eg, age of onset or when a measurement was performed. range: integer unit: ucum_code: d @@ -1017,12 +1021,12 @@ slots: range: uriorcurie processing: title: Sample Processing - description: Processing that was applied to the Parent Sample or from the - Biospecimen Collection that yielded this distinct sample. OBI is - recommended. + description: + Processing that was applied to the Parent Sample or from the Biospecimen Collection that yielded + this distinct sample. OBI is recommended. range: uriorcurie multivalued: true - availablity_status: + availability_status: title: Sample Availability description: Can this Sample be requested for further analysis? range: EnumAvailabilityStatus @@ -1046,35 +1050,33 @@ slots: range: float concentration_unit: title: Concentration Units - description: Units associated with the concentration of the analyte in the - Aliquot. + description: Units associated with the concentration of the analyte in the Aliquot. range: Concept age_at_collection: title: Age at Biospecimen Collection - description: The age at which this biospecimen was collected in decimal - years. + description: The age at which this biospecimen was collected in decimal years. range: float unit: ucum_code: a method: title: Biospecimen Collection Method description: The approach used to collect the biospecimen. - range: Concept - any_of: - - range: Concept - - range: EnumSampleCollectionMethod + range: EnumSampleCollectionMethod site: title: Biospecimen Collection Site description: The location of the specimen collection. range: Concept any_of: - range: Concept - - range: EnumSite + - range: EnumSampleCollectionMethod spatial_qualifier: title: Spatial Qualifier description: Qualifier that further refine the specific location of biospecimen collection - range: EnumSpatialQualifiers + range: Concept + any_of: + - range: Concept + - range: EnumSite laterality: title: Location Laterality description: Laterality that further refine the specific location of @@ -1110,8 +1112,9 @@ slots: range: EnumEDAMFormats file_extension: title: File Extension - description: Typically a 3-4 letter code at the end of a filename that - identifies the file format. Empty string for no extension. + description: + Typically a 3-4 letter code at the end of a filename that identifies the file format. + Empty string for no extension. range: string required: true data_type: @@ -1184,3 +1187,4 @@ slots: description: The date that data collection started. May include only a year. #TODO: We could re-evaluate these as dates, but that may be too implementation specific range: string + diff --git a/tests/data/invalid/DOI-001.yaml b/tests/data/invalid/DOI-001.yaml index 9b5fbca0..431213e1 100644 --- a/tests/data/invalid/DOI-001.yaml +++ b/tests/data/invalid/DOI-001.yaml @@ -1 +1 @@ -bibliographic_reference: "Test text" \ No newline at end of file +bibliographic_reference: "Test text" diff --git a/tests/data/valid/DOI-000.yaml b/tests/data/valid/DOI-000.yaml index 3e6391f5..e01ca930 100644 --- a/tests/data/valid/DOI-000.yaml +++ b/tests/data/valid/DOI-000.yaml @@ -1,2 +1,2 @@ do_id: "https://doi.org/10.71738/" -bibliographic_reference: "Test text" \ No newline at end of file +bibliographic_reference: "Test text" diff --git a/tests/data/valid/Subject-000.yaml b/tests/data/valid/Subject-000.yaml index dc9f8794..bf5476ba 100644 --- a/tests/data/valid/Subject-000.yaml +++ b/tests/data/valid/Subject-000.yaml @@ -1,2 +1,2 @@ subject_id: subject000 -subject_type: CAM:0000038 +subject_type: CAMO:0000024 diff --git a/tests/data/valid/Subject-001.yaml b/tests/data/valid/Subject-001.yaml index d435bd84..e987f180 100644 --- a/tests/data/valid/Subject-001.yaml +++ b/tests/data/valid/Subject-001.yaml @@ -1,2 +1,2 @@ subject_id: subject001 -subject_type: CAM:0000038 +subject_type: CAMO:0000024 diff --git a/tests/test_data.py b/tests/test_data.py index a70d61ce..91f84888 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1,17 +1,19 @@ """Data test.""" -import os + import glob -import pytest +import os from pathlib import Path -import common_access_model.datamodel.common_access_model +import pytest from linkml_runtime.loaders import yaml_loader +import common_access_model.datamodel.common_access_model + DATA_DIR_VALID = Path(__file__).parent / "data" / "valid" DATA_DIR_INVALID = Path(__file__).parent / "data" / "invalid" -VALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_VALID, '*.yaml')) -INVALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_INVALID, '*.yaml')) +VALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_VALID, "*.yaml")) +INVALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_INVALID, "*.yaml")) @pytest.mark.parametrize("filepath", VALID_EXAMPLE_FILES) @@ -25,7 +27,10 @@ def test_valid_data_files(filepath): obj = yaml_loader.load(filepath, target_class=tgt_class) assert obj + """This may not work for every expected error type- it uses ValueError""" + + @pytest.mark.parametrize("filepath", INVALID_EXAMPLE_FILES) def test_valid_data_files(filepath): """Test loading of all valid data files.""" @@ -36,4 +41,3 @@ def test_valid_data_files(filepath): ) with pytest.raises(Exception): obj = yaml_loader.load(filepath, target_class=tgt_class) -