armgilles / vcub_keeper

Analyse de l'activité des stations Vcub dans la métropole de Bordeaux afin de détecter en amont les stations hors service
https://vcubwatcher.herokuapp.com/
MIT License
2 stars 0 forks source link

Bench transf json to df #77

Closed armgilles closed 1 month ago

armgilles commented 1 year ago
armgilles commented 1 year ago

image

codecov[bot] commented 1 year ago

Codecov Report

Attention: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.21%. Comparing base (e3b4dd5) to head (9f47474). Report is 41 commits behind head on master.

Files with missing lines Patch % Lines
vcub_keeper/config.py 0.00% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #77 +/- ## ========================================== - Coverage 79.83% 79.21% -0.63% ========================================== Files 13 14 +1 Lines 362 380 +18 ========================================== + Hits 289 301 +12 - Misses 73 79 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

armgilles commented 1 year ago

Erreur during pytest-codspeed:

Run CodSpeedHQ/action@v1

   ______            __ _____                         __
  / ____/____   ____/ // ___/ ____   ___   ___   ____/ /
 / /    / __ \ / __  / \__ \ / __ \ / _ \ / _ \ / __  /
/ /___ / /_/ // /_/ / ___/ // /_/ //  __//  __// /_/ /
\____/ \____/ \__,_/ /____// .___/ \___/ \___/ \__,_/
  https://codspeed.io/     /_/          runner v1.5.0

Prepare environment
Run benchmarks
  valgrind: Bad option: --collect-systime=nsec
  valgrind: Invalid boolean value 'nsec' (should be 'yes' or 'no')
  valgrind: Use --help for more information or consult the user manual.
  Error: Failed to run benchmarks
armgilles commented 1 year ago

Lié à la version d'ubuntu (ubuntu-18.04 to ubuntu-22.04)

https://github.com/CodSpeedHQ/pytest-codspeed/issues/7#issuecomment-1486648336

armgilles commented 1 year ago

Error :

Run actions/setup-python@v3 Version 3.8.[5](https://github.com/armgilles/vcub_keeper/actions/runs/4588959029/jobs/8103521414#step:3:6) was not found in the local cache Error: Version 3.8.5 with arch x[6](https://github.com/armgilles/vcub_keeper/actions/runs/4588959029/jobs/8103521414#step:3:7)4 not found

image

Mettre la version ubuntu à 20.04.

armgilles commented 1 year ago

Still in error for ubuntu 20.04

image

armgilles commented 1 year ago

Upgrade python version in CI (python-version: 3.8.5 to python-version: 3.8.15

image

armgilles commented 1 year ago

Cf previous commit

Error on codspeed

`Prepare environment Environment ready Run benchmarks ============================= test session starts ============================== platform linux -- Python 3.8.15, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 codspeed: 1.2.2 rootdir: /home/runner/work/vcub_keeper/vcub_keeper plugins: cov-3.0.0, dash-2.3.1, codspeed-1.2.2, anyio-3.6.2 collected 0 items ================================ 0 benchmarked =================================

============================ no tests ran in 0.03s ============================= ERROR: file or directory not found: tests/

Error: Failed to run benchmarks`

armgilles commented 1 year ago
==================================== ERRORS ====================================
  ___________ ERROR collecting vcub_keeper/tests/test_api_data_bdx.py ____________
  ImportError while importing test module '/home/runner/work/vcub_keeper/vcub_keeper/vcub_keeper/tests/test_api_data_bdx.py'.
  Hint: make sure your test modules/packages have valid Python names.
  Traceback:
  /opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/importlib/__init__.py:127: in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  vcub_keeper/tests/test_api_data_bdx.py:5: in <module>
      from vcub_keeper.config import ROOT_TESTS_DATA
  E   ImportError: cannot import name 'ROOT_TESTS_DATA' from 'vcub_keeper.config' (/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/vcub_keeper-1.2.1-py3.8.egg/vcub_keeper/config.py)
  _________ ERROR collecting vcub_keeper/tests/test_transf_json_to_df.py _________
  ImportError while importing test module '/home/runner/work/vcub_keeper/vcub_keeper/vcub_keeper/tests/test_transf_json_to_df.py'.
  Hint: make sure your test modules/packages have valid Python names.
  Traceback:
  /opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/importlib/__init__.py:127: in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  vcub_keeper/tests/test_transf_json_to_df.py:5: in <module>
      from vcub_keeper.config import ROOT_TESTS_DATA
  E   ImportError: cannot import name 'ROOT_TESTS_DATA' from 'vcub_keeper.config' (/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/vcub_keeper-1.2.1-py3.8.egg/vcub_keeper/config.py)
  _ ERROR collecting vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py _
armgilles commented 1 year ago

Seems codespeed don't have correct environment.

armgilles commented 1 year ago

On my server : OK

pytest vcub_keeper/tests/benchmarks/ --codspeed

================================================================ test session starts ================================================================
platform linux -- Python 3.8.16, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
codspeed: 1.2.2
NOTICE: codspeed is enabled, but no performance measurement will be made since it's running in an unknown environment.
rootdir: /home/gillesa/github/vcub_keeper
plugins: codspeed-1.2.2, cov-3.0.0, dash-2.3.1
collected 1 item                                                                                                                                    

vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py .                                                                                [100%]
================================================================ 1 benchmark tested =================================================================

================================================================= warnings summary ==================================================================
../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:10
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:10: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _nlv = LooseVersion(_np_version)

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:11
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:11: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p16 = _nlv < LooseVersion("1.16")

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:12
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:12: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p17 = _nlv < LooseVersion("1.17")

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:13
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:13: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p18 = _nlv < LooseVersion("1.18")

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:14
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:14: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p19 = _nlv < LooseVersion("1.19")

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:15
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:15: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p20 = _nlv < LooseVersion("1.20")

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/setuptools/_distutils/version.py:351
vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py::test_benchmark_transf_json_to_df
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/setuptools/_distutils/version.py:351: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    other = LooseVersion(other)

../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/function.py:125
../../anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/function.py:125
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/numpy/function.py:125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(_np_version) >= LooseVersion("1.17.0"):

vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py::test_benchmark_transf_json_to_df
vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py::test_benchmark_transf_json_to_df
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/numexpr/expressions.py:21: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_forbids_neg_powint = LooseVersion(numpy.__version__) >= LooseVersion('1.12.0b1')

vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py::test_benchmark_transf_json_to_df
  /home/gillesa/anaconda3/envs/vcub_keeper_py38/lib/python3.8/site-packages/pandas/compat/_optional.py:100: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if distutils.version.LooseVersion(version) < minimum_version:

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================== 1 passed, 13 warnings in 0.56s ===========================================================

On github Action : KO

Prepare environment
  Environment ready
Run benchmarks
  ============================= test session starts ==============================
  platform linux -- Python 3.8.15, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
  codspeed: 1.2.2
  rootdir: /home/runner/work/vcub_keeper/vcub_keeper
  plugins: cov-3.0.0, dash-2.3.1, codspeed-1.2.2, anyio-3.6.2
  collected 0 items / 1 error
  ================================ 0 benchmarked =================================

  ==================================== ERRORS ====================================
  _ ERROR collecting vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py _
  ImportError while importing test module '/home/runner/work/vcub_keeper/vcub_keeper/vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py'.
  Hint: make sure your test modules/packages have valid Python names.
  Traceback:
  /opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/importlib/__init__.py:1[27](https://github.com/armgilles/vcub_keeper/actions/runs/4589529335/jobs/8104480034#step:8:29): in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py:5: in <module>
      from vcub_keeper.config import ROOT_TESTS_DATA
  E   ImportError: cannot import name 'ROOT_TESTS_DATA' from 'vcub_keeper.config' (/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/vcub_keeper-1.2.1-py3.8.egg/vcub_keeper/config.py)
  ------------------------------- Captured stdout --------------------------------
  Can't have repository variables

BTW, it's working during classic tests (coverage run -m pytest) but not during CodSpeed !

garaud commented 1 year ago

Peut-être que la variable n'est pas définie dans le except

https://github.com/armgilles/vcub_keeper/blob/master/vcub_keeper/config.py#L30

à cause d'un soucis de config / environnement "prod" ou "preprod".

armgilles commented 1 year ago

Error

==================================== ERRORS ====================================
  _ ERROR collecting vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py _
  vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py:19: in <module>
      station_json_loaded = read_json_data()
  vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py:14: in read_json_data
      with open(ROOT_TESTS_DATA + file_name) as f:
  E   TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
armgilles commented 1 year ago

Yep that's right @garaud. ROOT_DIR seems None

Package is installed in '/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/vcub_keeper-1.2.1-py3.8.egg/ so it goes to If package is install with pip https://github.com/armgilles/vcub_keeper/blob/e3b4dd541c1e71d14d9254fde0df043b7f6d0a91/vcub_keeper/config.py#L18

I have to find a way to get rootdir (see log) in Github action to get the correct path and can use ROOT_TESTS_DATA with this path.

============================= test session starts ==============================
  platform linux -- Python 3.8.15, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
  codspeed: 1.2.2
  rootdir: /home/runner/work/vcub_keeper/vcub_keeper
  plugins: cov-3.0.0, dash-2.3.1, codspeed-1.2.2, anyio-3.6.2
  collected 0 items / 1 error
  ================================ 0 benchmarked =================================

  ==================================== ERRORS ====================================
  _ ERROR collecting vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py _
  vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py:19: in <module>
      station_json_loaded = read_json_data()
  vcub_keeper/tests/benchmarks/test_bench_transf_json_to_df.py:14: in read_json_data
      with open(ROOT_TESTS_DATA + file_name) as f:
  E   FileNotFoundError: [Errno 2] No such file or directory: '/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/vcub_keeper-1.2.1-py3.8.egg/vcub_keeper/tests/data_for_tests/data_test_api_from_bdx.json'
  ------------------------------- Captured stdout --------------------------------
armgilles commented 1 month ago

Done with #91