Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference SDK missing requirement when running tests #284

Closed
2 tasks done
amaloney opened this issue Feb 23, 2024 · 1 comment
Closed
2 tasks done

Inference SDK missing requirement when running tests #284

amaloney opened this issue Feb 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@amaloney
Copy link

Search before asking

  • I have searched the Inference issues and found no similar bug report.

Bug

_ ERROR collecting tests/inference_sdk/unit_tests/http/test_client.py _
ImportError while importing test module '/home/perovskite/Development/professional/open-source/roboflow/inference-dev/inference/tests/inference_sdk/unit_tests/http/test_client.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../../mambaforge/envs/inference-dev/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
inference/tests/inference_sdk/unit_tests/http/test_client.py:11: in <module>
    from requests_mock.mocker import Mocker
E   ModuleNotFoundError: No module named 'requests_mock'

_ ERROR collecting tests/inference_sdk/unit_tests/http/utils/test_executors.py _
ImportError while importing test module '/home/perovskite/Development/professional/open-source/roboflow/inference-dev/inference/tests/inference_sdk/unit_tests/http/utils/test_executors.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../../mambaforge/envs/inference-dev/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
inference/tests/inference_sdk/unit_tests/http/utils/test_executors.py:9: in <module>
    from requests_mock import Mocker
E   ModuleNotFoundError: No module named 'requests_mock'

Environment

  • Inference: 0.9.14rc2 (dev install from main)
  • OS: arch linux
  • Device: macbook pro
  • Python: 3.11.8
  • mamba virtual env

Minimal Reproducible Example

I am using a mamba environment with the provided minimal environment file below in the code section. Any virtual environment will work, I'm using mamba as it is one of the tools I use most often.

I wanted to see the state of tests for each of the inference packages in the repo, so I was selectively installing the requirements using pip in my mamba environment with the following command.

# SDK requirements
pip install -r requirements/requirements.sdk.http.txt

After installation completed, I ran tests using the following command. I created an HTML coverage output so I could inspect tests that I might be able to contribute to.

pytest --cov-report html --cov=inference_sdk/ tests/inference_sdk/

The error show above was thrown, indicating that requests-mock was missing in the environment. I'm not sure if each requirement file is supposed to be self contained for running the different packages in the repo, but I did make this assumption and I couldn't easily see in the documentation a spot where it said this was not the case. So, I may have made a terrible assumption...

Nonetheless, I inspected the requirements.sdk.http.txt file and saw that requests-mock was not in the list. After adding it, and rerunning the tests, the tests completed successfully. If each requirements file is supposed to be self contained for a specific package in the repo, then requests-mock is missing as a requirement. If not, then I need to read the documentation more closely to figure out the correct order of operations for installing inference in a development environment.

code

# environment.yaml
name: inference-dev
channels:
  - conda-forge
dependencies:
  - python >3.8,<3.12

  # Dependencies

  # Package managers
  - pip

  # Development dependencies
  - black
  - flake8
  - isort
  - jupyterlab
  - pip:
    - pyre-check

  # Debugging dependencies
  - ipdb
  - pytest
  - pytest-asyncio
  - pytest-cov

  # Documents dependencies
  - mkdocs
  - mkdocstrings
  - mkdocstrings-python

Additional

During my inspection of the requirements.sdk.http.txt file I noticed that requests is listed twice. I figured this out by sorting the requirements.

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@amaloney amaloney added the bug Something isn't working label Feb 23, 2024
@amaloney amaloney mentioned this issue Feb 23, 2024
2 tasks
@PawelPeczek-Roboflow
Copy link
Collaborator

We do work to clarify setup, but we also decided not to add test requirement into package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants