Skip to content

Conversation

@pulltheflower
Copy link

Related to issue #3494

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin
Copy link
Contributor

Wauplin commented Oct 30, 2025

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Style bot fixed some files and pushed the changes.

@pulltheflower
Copy link
Author

@Wauplin I noticed a large number of build and test failures, which seem to be related to network issues. Could this possibly be connected to my changes? I’d appreciate it if you could take a look, thank you!

@Wauplin
Copy link
Contributor

Wauplin commented Oct 31, 2025

I noticed a large number of build and test failures, which seem to be related to network issues.

Yes that was due to temporary issues on our staging infra. It is now resolved.

Note that there are still a few issues due to this PR. See all the

FAILED ../tests/test_hf_api.py::RepoUrlTest::test_repo_url_class - ValueError: not enough values to unpack (expected 2, got 1)
FAILED ../tests/test_hf_api.py::ParseHFUrlTest::test_repo_type_and_id_from_hf_id_on_wrong_values - AssertionError: ValueError not raised
FAILED ../tests/test_hf_api.py::RepoUrlTest::test_repo_url_endpoint - ValueError: not enough values to unpack (expected 2, got 1)
FAILED ../tests/test_hf_api.py::RepoUrlTest::test_repo_url_namespace - ValueError: not enough values to unpack (expected 2, got 1)

looking into the details, this line is now failing.

Could you have a look at it please?

@pulltheflower pulltheflower force-pushed the enhance-repo-type-and-id-parser-of-hf-api branch from 48c26fa to 6adcdf1 Compare November 18, 2025 07:15
@pulltheflower
Copy link
Author

@Wauplin Sorry for taking so long to fix the tests. Could you please trigger the pipeline again?

@pulltheflower pulltheflower force-pushed the enhance-repo-type-and-id-parser-of-hf-api branch from 13ed689 to 136c1fc Compare November 19, 2025 05:26
@pulltheflower
Copy link
Author

@Wauplin There were still some failing tests in the previous commit, but I’ve fixed them in the latest commit.

@pulltheflower
Copy link
Author

image

@Wauplin The test is passing successfully in my local environment but failing in the CI/CD pipeline. Could you please take a look and help identify what might be causing this discrepancy?

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Great @pulltheflower ! All tests are now passing correctly (the failing CI was not related to your PR). Last tiny comment, could you address the regex optimization comment below? Apart from that implementation looks good and tests are nice (I've also played with it a bit locall)

is_hf_url = hub_url in hf_id and "@" not in hf_id
# Get the hub_url (with or without protocol)
full_hub_url = hub_url if hub_url is not None else constants.ENDPOINT
hub_url_without_protocol = re.sub(r"https?://", "", full_hub_url)
Copy link
Contributor

Choose a reason for hiding this comment

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

Slight optimization but could you define a root-level _REGEX_HTTP_PROTOCOL = re.compile(r"https?://") variable (next to _REGEX_DISCUSSION_URL for instance) and then use

hub_url_without_protocol = _REGEX_HTTP_PROTOCOL.sub("", full_hub_url)

It prevents Python from having to compile the regex on each call

hub_url_without_protocol = re.sub(r"https?://", "", full_hub_url)

# Check if hf_id is a URL containing the hub_url (check both with and without protocol)
hf_id_without_protocol = re.sub(r"https?://", "", hf_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

reused here

# If it's a URL, strip the endpoint prefix to get the path
if is_hf_url:
# Remove protocol if present
hf_id_normalized = re.sub(r"https?://", "", hf_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

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