BUG-FIXED : FileNotFoundError: CI/CD pipelines with GitHub Actions

I have file not found error:

Run pytest
  pytest
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.11.1/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.1/x64/lib
============================= test session starts ==============================
platform linux -- Python 3.11.1, pytest-7.3.1, pluggy-1.0.0
rootdir: /home/runner/work/MLOps-Coursera/MLOps-Coursera/course4/week3-ungraded-labs/C4_W3_Lab_4_Github_Actions
plugins: anyio-3.6.2
collected 0 items / 1 error

==================================== ERRORS ====================================
_______________________ ERROR collecting app/test_clf.py _______________________
app/test_clf.py:2: in <module>
    from main import clf
app/main.py:12: in <module>
    with open("models/wine-95-fixed.pkl", "rb") as file:
E   FileNotFoundError: [Errno 2] No such file or directory: 'models/wine-95-fixed.pkl'
=========================== short test summary info ============================
ERROR app/test_clf.py - FileNotFoundError: [Errno 2] No such file or directory: 'models/wine-95-fixed.pkl'
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.24s ===============================
Error: Process completed with exit code 2.

As we changing the working directory as
working-directory: course4/week3-ungraded-labs/C4_W3_Lab_4_Github_Actions/

I fixed it by adding the relative path:
app/models/wine-95-fixed.pkl

and same for loading test data
app/data/test_data.pkl

Hope it helps if you are struggling with above error.

Good day and keep learning!
Abonia

Thank you for sharing your solution to the pytest error you encountered. I appreciate you taking the time to share your solution and provide helpful tips for others who may be struggling with similar issues. Keep up the great work and happy learning!

Best,
Saif.

1 Like