Skip to content

test: add unit tests for get_previous_step_or_raise (#1908)#3218

Merged
severo merged 10 commits into
huggingface:mainfrom
ArjunJagdale:patch-6
Jul 11, 2025
Merged

test: add unit tests for get_previous_step_or_raise (#1908)#3218
severo merged 10 commits into
huggingface:mainfrom
ArjunJagdale:patch-6

Conversation

@ArjunJagdale

Copy link
Copy Markdown
Contributor

This PR adds unit tests for the get_previous_step_or_raise function, as requested in issue #1908.

The test cases include:

  • A successful cache hit (returns response)
  • No cache found (raises CachedArtifactNotFoundError)
  • Error status in cache (raises CachedArtifactError)

Note: I wasn't able to run the tests locally due to import resolution issues (libcommon), but the test logic is clean, uses official helpers (upsert_response, delete_response), and CI should be able to describe the issue more accurately (if any occurs).

Tests are added at the bottom of test_simple_cache.py

@severo severo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice addition! Please fix the linting issue and we can merge

@ArjunJagdale

ArjunJagdale commented Jul 10, 2025

Copy link
Copy Markdown
Contributor Author

Hi @severo, I’ve addressed the import linting issue using isort, and all the imports should be now grouped and ordered correctly.

but still facing Ruff Linter?:

Run if [ -d src ]; then poetry run ruff check src; fi
All checks passed!
tests/test_simple_cache.py:4:1: I001 [*] Import block is un-sorted or un-formatted
Found 1 error.
[*] 1 fixable with the `--fix` option.
Error: Process completed with exit code 1.

@severo

severo commented Jul 10, 2025

Copy link
Copy Markdown
Collaborator

The way we do it is to go to libs/libcommon and run make style.

Another way is to install the ruff extension in vscode (if you use it) and autoformat/lint on save

@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

i tried using ruff by ruff format and also as a VS CODE extension, still failing.

@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

Hi @severo, just wanted to share a quick update:

I followed the Hugging Face workflow using poetry install + make style. That worked fine. but nothing in the file I touched (test_simple_cache.py).

@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

Maybe this time it'll work

@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

test_simple_cache_log.txt

Here's the log

@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

-> None was missing for test functions

@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

Also, assign me or consider me for other issues — I’d love to help however I can!

@severo

severo commented Jul 11, 2025

Copy link
Copy Markdown
Collaborator

Cool, good contribution!

@severo severo merged commit 49d78b9 into huggingface:main Jul 11, 2025
21 of 22 checks passed
@ArjunJagdale

Copy link
Copy Markdown
Contributor Author

Thank you!

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.

2 participants