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

pyOpenMS: Log warnings in pure Python code with warnings.warn instead of print #7418

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

RalfG
Copy link
Contributor

@RalfG RalfG commented Mar 28, 2024

Description

Revisit of #6979. Replacing print statements in pyopenms/__init__.py with warnings.warn for info regarding the OPENMS_DATA_PATH environment variable.

If I understand correctly, #6979 was closed because it proposed to use the logging module, leading to multiple ways of logging implemented in pyOpenMS. I here propose to use warnings.warn instead in the pure Python code. Especially in the case of the OPENMS_DATA_PATH warnings, this makes sense.

Currently, using pyOpenMS with multiprocessing leads to a wall of warnings that cannot be disabled due to the use of print. With the proposed changes, developers of tools using pyOpenMS can choose to ignore these warnings when desired with

from warnings import filterwarnings

filterwarnings(
    "ignore",
    message="OPENMS_DATA_PATH environment variable already exists",
    category=UserWarning,
    module="pyopenms",
)

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out
  • The details of the action statuses at the end of the PR or the "Checks" tab.
  • http://cdash.openms.de/index.php?project=OpenMS and look for your PR. Use the "Show filters" capability on the top right to search for your PR number.
    If you click in the column that lists the failed tests you will get detailed error messages.

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

@jpfeuffer
Copy link
Contributor

Yes, the referenced PR was only closed because they were looking for a way to control all logs and the logs and the ones coming from C++ require more work.
I'm fine with at least doing the python logs a bit nicer.

@timosachsenberg timosachsenberg merged commit 6d1d5e2 into OpenMS:develop Mar 28, 2024
11 of 13 checks passed
@timosachsenberg
Copy link
Contributor

Thanks!

@radusuciu
Copy link
Contributor

Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants