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

Fix telemetry issues in wheel build and unit tests #4591

Merged
merged 22 commits into from
Nov 19, 2024

Conversation

kratman
Copy link
Contributor

@kratman kratman commented Nov 15, 2024

Description

Fixes the wheel build and updates the telemetry code to make sure it does not run during tests

Fixes #4588

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@kratman kratman self-assigned this Nov 15, 2024
Copy link
Contributor Author

@kratman kratman left a comment

Choose a reason for hiding this comment

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

Explanations of the changes

Comment on lines +120 to +121
CIBW_ENVIRONMENT: >
PYBAMM_DISABLE_TELEMETRY="true"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can tell the environment variables were not making it into the CIBW environment. This disables telemetry in the wheel tests

@@ -132,7 +131,6 @@ jobs:

# Skips IDAKLU module compilation for speedups, which is already tested in other jobs.
run_doctests:
needs: style
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If style fails then PR is updated with the pre-commit fixes and the old jobs get canceled. This just speeds up the start of the jobs a bit

@@ -49,7 +49,6 @@ def set_iree_state():
"IREE_INDEX_URL": os.getenv(
"IREE_INDEX_URL", "https://iree.dev/pip-release-links.html"
),
"PYBAMM_DISABLE_TELEMETRY": "true",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I could tell, this was not working. It seemed like telemetry was still running in tests.

if any(var in os.environ for var in ci_env_vars):
return True

# Check for common test runner names in command-line arguments
test_runners = ["pytest", "unittest", "nose", "trial", "nox", "tox"]
if any(runner in arg.lower() for arg in sys.argv for runner in test_runners):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This did not seem to work on Mac or Windows. I was seeing nox and pytest commands go right past this. I tested it by moving it to the top of the file and putting an assert below it.

@@ -110,7 +116,7 @@ def get_input(): # pragma: no cover


def generate():
if is_running_tests():
if is_running_tests() or check_opt_out():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since is_running_tests() does not work in all CI cases, I put the opt-out check here to provide another escape


config = pybamm.config.read()
if config:
if config["enable_telemetry"]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is now in the check_out_out() function, so it is redundant here

@@ -336,12 +336,12 @@ def no_internet_connection():
conn = socket.create_connection((host, 80), 2)
conn.close()
return False
except socket.gaierror:
except (socket.gaierror, TimeoutError):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sometimes I get timeouts from the no_internet_connection() function. This makes that also count as "not connection", but since I was actively connected to the internet, I don't think this function is working as expected.

@kratman kratman changed the title Fix/telemetry Fix telemetry issues in wheel build and unit tests Nov 15, 2024
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.25%. Comparing base (bcdd0b5) to head (f31fae1).
Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4591      +/-   ##
===========================================
- Coverage    99.26%   99.25%   -0.02%     
===========================================
  Files          302      302              
  Lines        22889    22906      +17     
===========================================
+ Hits         22721    22735      +14     
- Misses         168      171       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@kratman
Copy link
Contributor Author

kratman commented Nov 16, 2024

Coverage is easy to fix. I will do that before I mark it ready for review

@kratman kratman marked this pull request as ready for review November 18, 2024 00:53
@kratman
Copy link
Contributor Author

kratman commented Nov 18, 2024

Wheel build passed, this should be ready for the release

@kratman kratman added the release blocker Issues that need to be addressed before the creation of a release label Nov 18, 2024
@kratman kratman merged commit 6c7c21a into pybamm-team:develop Nov 19, 2024
25 of 26 checks passed
@kratman kratman deleted the fix/telemetry branch November 20, 2024 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release blocker Issues that need to be addressed before the creation of a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fortnightly build for wheels failed
2 participants