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

Coverage update #42

Merged
merged 7 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bugfixes + use pyproject.toml instead of .coveragerc
  • Loading branch information
rigoudyg committed Jan 24, 2025
commit d8e34b550248f0f92fb7d0219d489a3b4d19a74b
2 changes: 1 addition & 1 deletion data_request_api/stable/query/data_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from data_request_api.stable.utilities.tools import read_json_file
from data_request_api.stable.query.vocabulary_server import VocabularyServer, is_link_id_or_value, build_link_from_id

version = "0.1"
version = "1.0.1"


class ConstantValueObj(object):
Expand Down
4 changes: 0 additions & 4 deletions launch_test_with_coverage.sh

Choose a reason for hiding this comment

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

Ran for me, and the html report htmlcov/index.html is very nice! It took a long time to run, maybe 20 min... should it?

Does the six module need to be added as a dependency?

Can this file and .coveragerc be moved into tests/ just to keep the top-level repo dir uncluttered?

Copy link
Author

Choose a reason for hiding this comment

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

I don't think we need to add the six package as dependency but I may be wrong as we are in python3. Did you have issues with it when you run the API the first time?

The htmlcov directory can be customed through .coveragerc. I will change the default value to a place in the tests directory in my branch.
I'm not sure that we can move the .coveragerc (it won't be taken into account if I do so).

Copy link
Author

Choose a reason for hiding this comment

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

I have checked and I change the locations of the temporary files and .coveragerc too.

Copy link
Author

@rigoudyg rigoudyg Jan 23, 2025

Choose a reason for hiding this comment

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

To be done once #39 will be merged, change the default cache for pytest in the pyproj.toml file :
[pytest]
cache_dir = tests/.pytest_cache

Copy link
Author

Choose a reason for hiding this comment

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

The tests are quite long because some scripts make the splitting from the single and the several databases.

Copy link

Choose a reason for hiding this comment

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

I have just tested the launch_test_with_coverage.sh script and it works fine, rolling all the coverage tests (about 20 min as for @JamesAnstey) with a nice html view. Well done @rigoudyg 👍

Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-

export COVERAGE_RCFILE=tests/.coveragerc

coverage erase

coverage run
# To be moved before once tests are fixed
set -e
coverage run --parallel-mode scripts/database_transformation.py --output_dir="test" --dreq_export_version="raw"
coverage run --parallel-mode scripts/database_transformation.py --output_dir="test" --dreq_export_version="release"
coverage run --parallel-mode scripts/export_dreq_lists_json.py --all_opportunities "v1.0" "result.json"
rm -f result.json
coverage run --parallel-mode scripts/workflow_example.py
rm -f "requested_v1.0.json" "requested_raw.json"
coverage run --parallel-mode scripts/workflow_example_2.py --output_dir="test" --dreq_export_version="raw"
Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,33 @@ Issues = "https://github.com/CMIP-Data-Request/CMIP7_DReq_Software/issues"
# modules and functions that act as command line utilities to be specified here
# use pip install -e . from the root directory of the repository to set up the entry points
export_dreq_lists_json = "data_request_api.command_line.export_dreq_lists_json:main"

[tool.pytest.ini_options]
cache_dir = "tests/.pytest_cache"

[tool.coverage.run]
branch = true
parallel = true
command_line = "-m pytest"
source = [
"data_request_api/stable"
]
data_file = "tests/.coverage"

[tool.coverage.report]
fail_under = 50
exclude_lines = [
'if __name__ == "__main__":'
]

[tool.coverage.html]
directory = "tests/htmlcov"

[tool.coverage.xml]
output = "tests/coverage.xml"

[tool.coverage.json]
output = "tests/coverage.json"

[tool.coverage.lcov]
output = "tests.coverage.lcov"
3 changes: 3 additions & 0 deletions scripts/database_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import tempfile


sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


import data_request_api.stable.content.dreq_api.dreq_content as dc
from data_request_api.stable.content.dump_transformation import transform_content
from data_request_api.stable.utilities.tools import write_json_output_file_content
Expand Down
6 changes: 6 additions & 0 deletions scripts/workflow_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
./export_dreq_lists_json.py v1.0 dreq_list.json --opportunities_file opps.json

'''
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from data_request_api.stable.content.dreq_api import dreq_content as dc
from data_request_api.stable.query import dreq_query as dq
from importlib import reload
Expand Down
24 changes: 0 additions & 24 deletions tests/.coveragerc

This file was deleted.

Loading