Skip to content

Adding test for any_of at the class level.#2292

Merged
amc-corey-cox merged 9 commits into
mainfrom
issue-2282-any-of-at-class-level
May 7, 2026
Merged

Adding test for any_of at the class level.#2292
amc-corey-cox merged 9 commits into
mainfrom
issue-2282-any-of-at-class-level

Conversation

@cmungall

Copy link
Copy Markdown
Member

Fixes #2282

@sneakers-the-rat

Copy link
Copy Markdown
Collaborator

what would the difference between slot_conditions: slot: required: True and slot_usage: slot: required: True here be?

@sierra-moxon

Copy link
Copy Markdown
Member

merged upstream fixes for CQ and linting

@codecov

codecov Bot commented May 16, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.39%. Comparing base (373cba1) to head (64ea507).

Files with missing lines Patch % Lines
...ages/linkml/src/linkml/generators/jsonschemagen.py 65.00% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2292      +/-   ##
==========================================
+ Coverage   80.95%   84.39%   +3.43%     
==========================================
  Files         156      156              
  Lines       18413    18433      +20     
  Branches     3848     3856       +8     
==========================================
+ Hits        14907    15557     +650     
+ Misses       2673     1994     -679     
- Partials      833      882      +49     
Flag Coverage Δ
linkml 80.93% <65.00%> (-0.02%) ⬇️
runtime 80.93% <65.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add handling for boolean class expressions (any_of, all_of, exactly_one_of,
none_of) in the JSON Schema generator's generate_class method. This enables
patterns like requiring either a `name` OR both `family_name` and `given_name`
using slot_conditions with required: true inside class-level any_of.

Fixes #2282
@kevinschaper kevinschaper force-pushed the issue-2282-any-of-at-class-level branch from b285e2d to 42e59ea Compare April 1, 2026 21:34
Copilot AI review requested due to automatic review settings April 1, 2026 21:34

@kevinschaper kevinschaper 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.

I ended up doing a force push to bring these changes into a fresh branch, to avoid pre-monorepo merge nightmares.

Copilot AI 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.

Pull request overview

Adds JSON Schema generator support (and compliance coverage) for class-level boolean constraints that can drive conditional required slots, addressing #2282.

Changes:

  • Added a new compliance test covering class-level any_of/all_of that conditionally require different slot sets (including nested/inlined scenarios).
  • Updated JsonSchemaGenerator.handle_class to emit class-level anyOf/allOf/oneOf/not(anyOf) from ClassDefinition boolean expressions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tests/linkml/test_compliance/test_boolean_slot_compliance.py Adds a new parametrized compliance test for class boolean constraints affecting requiredness (including nested case).
packages/linkml/src/linkml/generators/jsonschemagen.py Emits JSON Schema boolean keywords for class-level any_of, all_of, exactly_one_of, and none_of.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/linkml/test_compliance/test_boolean_slot_compliance.py Outdated
Comment thread tests/linkml/test_compliance/test_boolean_slot_compliance.py Outdated
Comment thread tests/linkml/test_compliance/test_boolean_slot_compliance.py Outdated
Comment thread packages/linkml/src/linkml/generators/jsonschemagen.py Outdated
Comment thread packages/linkml/src/linkml/generators/jsonschemagen.py Outdated
kevinschaper and others added 7 commits April 1, 2026 15:17
…ctly_one_of/none_of tests

- Use boolean True instead of string "true" for required in test schema
- Use dynamic op parameter in core_elements instead of hard-coded "any_of"
- Add exactly_one_of and none_of parametrize cases to test_class_any_of_with_required
- Fix line-too-long in description f-string

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread tests/linkml/test_compliance/test_boolean_slot_compliance.py Outdated
@amc-corey-cox amc-corey-cox merged commit 64f6a21 into main May 7, 2026
17 checks passed
@noelmcloughlin noelmcloughlin deleted the issue-2282-any-of-at-class-level branch May 7, 2026 16:05
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.

using boolean constraints on required state

8 participants