Skip to content

fix(linkml_files): correct GitHub raw/pages URLs and convert tests to pytest#257

Merged
amc-corey-cox merged 2 commits into
mainfrom
fix-linkml-files-github-urls
Jun 8, 2026
Merged

fix(linkml_files): correct GitHub raw/pages URLs and convert tests to pytest#257
amc-corey-cox merged 2 commits into
mainfrom
fix-linkml-files-github-urls

Conversation

@amc-corey-cox

Copy link
Copy Markdown
Contributor

What

Two related changes to linkml_model/linkml_files.py and its tests:

1. Fix broken GitHub URL builders

GITHUB_IO_PATH_FOR and GITHUB_PATH_FOR (branch/latest) currently emit URLs that 404. The schema/artifact files are published under the linkml_model/ package directory on GitHub (both raw and GitHub Pages), but these builders omitted that path segment. LOCAL_PATH_FOR was unaffected because its base already points inside the package.

Verified before/after (live curl):

| Function | before | after |
| GITHUB_PATH_FOR(META, YAML, LATEST) | …/main/model/schema/meta.yaml404 | …/main/linkml_model/model/schema/meta.yaml200 |
| GITHUB_IO_PATH_FOR(META, YAML) | …/model/schema/meta.yaml404 | …/latest/linkml_model/model/schema/meta.yaml200 |

GITHUB_IO_PATH_FOR gains an optional version="latest" argument since the docs site is versioned (<version>/linkml_model/…). The signature change is backward-compatible.

Known limitation: the tag/release path (tag_to_commit) now also uses the linkml_model/ prefix, which is correct for all modern (v1.x) releases. Pre-restructure tags such as v0.0.1 stored artifacts at the repo root, so URLs built for those very old tags are correct in form but will not resolve. Layout-aware detection was deliberately skipped as overkill.

2. Convert tests/test_linkml_files.py to pytest

Replaces the unittest.TestCase style with functional pytest, and splits the monolithic test_basic_rules so each function (URL_FOR, LOCAL_PATH_FOR, GITHUB_IO_PATH_FOR, GITHUB_PATH_FOR) is covered separately. The live GitHub-API test is now opt-in via LINKML_TEST_GITHUB_API=1 (rate-limited / flaky in CI) instead of a hardcoded skip flag.

Context

This picks up the still-relevant pieces of the long-stale #201. The bulk of that PR (the Format/_Path refactor) already landed on main independently; the URL fix and pytest conversion did not. #201 will be closed as superseded, referencing this PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates linkml_model/linkml_files.py to generate correct GitHub Raw and GitHub Pages URLs for published schema/artifact files (which live under the linkml_model/ package directory), and modernizes the associated test suite by converting it from unittest to pytest.

Changes:

  • Fix GitHub raw URL construction to include the linkml_model/ path prefix (branch/latest and tag-resolved URLs).
  • Add a version="latest" parameter to GITHUB_IO_PATH_FOR so GitHub Pages URLs can target versioned docs paths (<version>/linkml_model/...).
  • Convert tests/test_linkml_files.py to pytest, split coverage by function, and make GitHub-API network tests opt-in.

Reviewed changes

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

File Description
linkml_model/linkml_files.py Updates GitHub URL builders to include the linkml_model/ package path; adds versioning support for GitHub Pages URLs.
tests/test_linkml_files.py Migrates tests to pytest, updates expected URLs, and gates live GitHub API tests behind an environment variable.

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

Comment thread tests/test_linkml_files.py
Comment thread tests/test_linkml_files.py Outdated

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

This looks good, but I only partially understand this; would appreciate a quick @dalito look.

@dalito dalito left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The way the corrected linkml_model/-prefixed raw and Pages URLs are constructed looks correct to me.

@amc-corey-cox
amc-corey-cox merged commit 1e8c0a2 into main Jun 8, 2026
8 checks passed
@amc-corey-cox
amc-corey-cox deleted the fix-linkml-files-github-urls branch June 8, 2026 19:46
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.

4 participants