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

Use Python logging system for emitting log messages when running via the Python API #159

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

hoechenberger
Copy link
Owner

@hoechenberger hoechenberger commented Apr 13, 2024

Fixes #141

Adds a cli_only kwarg to emit some log messages only when running from the CLI.

@hoechenberger
Copy link
Owner Author

@cbrnr Care to test if this works? I don't think the logger honors existing tqdm output, but maybe this is not a problem – I haven't tested it yet

@hoechenberger hoechenberger changed the title Use Python logging system for emitting log messages when called from the Python API Use Python logging system for emitting log messages when running via the Python API Apr 13, 2024
@hoechenberger

This comment was marked as resolved.

@hoechenberger

This comment was marked as resolved.

@hoechenberger hoechenberger marked this pull request as ready for review April 13, 2024 18:29
@hoechenberger hoechenberger requested a review from larsoner April 13, 2024 18:30
@hoechenberger
Copy link
Owner Author

Screenshot 2024-04-14 at 14 47 52

Problems:

  • Repeated messages regarding using the token
  • Token isn't even needed for this dataset
  • HTTP status codes

@cbrnr
Copy link
Contributor

cbrnr commented Apr 15, 2024

The token messages also appear on main? Or are they directly caused by changes in this PR?

@hoechenberger
Copy link
Owner Author

The token messages also appear on main? Or are they directly caused by changes in this PR?

I don't know. I would believe it also appears in main.

@cbrnr
Copy link
Contributor

cbrnr commented Apr 15, 2024

OK, so the problems you listed (at least the first two) are not related to this PR and should probably fixed in another PR.

@hoechenberger
Copy link
Owner Author

I believe so. Any help in verifying and tracking this would be appreciated!

Copy link
Collaborator

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

LGTM, merged main to hopefully get CIs green

@hoechenberger
Copy link
Owner Author

Nice! Once we have a changelog message, we can merge

@hoechenberger
Copy link
Owner Author

I had totally forgotten about this one.
@cbrnr @larsoner Do we still want this? 🙂

Copy link
Collaborator

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

One tiny suggestion but don't have to take it

No strong opinion here since I use the CLI exclusively but changes LGTM

message will shop up when running from the CLI and the Python API.

"""
from openneuro import _RUNNING_FROM_CLI # avoid circular import
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than this it seems a tiny bit cleaner to have a global var in this file. Then here you don't need any import and above...

@@ -61,6 +61,8 @@ def download_cli(
] = 5,
) -> None:
"""Download datasets from OpenNeuro."""
openneuro._RUNNING_FROM_CLI = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can have this:

Suggested change
openneuro._RUNNING_FROM_CLI = True
openneuro._logging._RUNNING_FROM_CLI = True

(along with an import openneuro._logging at the top)

@cbrnr
Copy link
Contributor

cbrnr commented Jan 7, 2025

For people using it as a module I think this would be useful, so despite the added complexity I'd still go for it. I'd also apply Eric's suggestion.

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.

Log info messages
3 participants