Skip to content

Conversation

@ialarmedalien
Copy link
Collaborator

This is a minor edit to allow detect_cycles to take a list of nodes as input instead of restricting it to a single node.

:raises ValueError: if a cycle is discovered through repeated calls to f(node)
"""
# ensure we have some nodes to start the analysis
if not node_list or not isinstance(node_list, Iterable) or isinstance(node_list, str):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

make sure that the input is a non-empty iterable and that it isn't a string (which is an iterable, but probably not one that we need to detect cycles in!).

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.10%. Comparing base (9e0e62b) to head (2fe479e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
linkml_runtime/utils/schemaview.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #476      +/-   ##
==========================================
+ Coverage   78.08%   78.10%   +0.01%     
==========================================
  Files          52       52              
  Lines        4508     4512       +4     
  Branches      982      983       +1     
==========================================
+ Hits         3520     3524       +4     
  Misses        769      769              
  Partials      219      219              

☔ 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.

"""
if kwargs and kwargs.get("detect_cycles"):
detect_cycles(f, x)
detect_cycles(f, [x])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

currently this is the only place in the code where detect_cycles is called directly

"""Test detection of cycles in the types segment of the cycles schema."""
if fn == "detect_cycles":
with pytest.raises(ValueError, match=f"Cycle detected at node '{cycle_start_node}'"):
detect_cycles(lambda x: sv_cycles_schema.type_parents(x), target)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

don't need these lambdas - can just supply the function

Copy link
Contributor

@amc-corey-cox amc-corey-cox left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@amc-corey-cox amc-corey-cox merged commit add14ac into main Oct 22, 2025
17 checks passed
@amc-corey-cox amc-corey-cox deleted the schemaview_detect_cycles_node_list_args branch October 22, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants