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

Fixed NeptuneLogger support across different versions of neptune package #19131

Conversation

Raalsky
Copy link
Contributor

@Raalsky Raalsky commented Dec 8, 2023

What does this PR do?

Fixes #18555

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚 : https://pytorch-lightning--19131.org.readthedocs.build/en/19131/

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Dec 8, 2023
@Raalsky Raalsky requested a review from Borda as a code owner December 9, 2023 07:26
Copy link

codecov bot commented Dec 9, 2023

Codecov Report

Merging #19131 (a2d921e) into master (df869c9) will decrease coverage by 34%.
Report is 2 commits behind head on master.
The diff coverage is 81%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19131      +/-   ##
==========================================
- Coverage      83%      49%     -34%     
==========================================
  Files         443      435       -8     
  Lines       36764    36616     -148     
==========================================
- Hits        30617    17981   -12636     
- Misses       6147    18635   +12488     

@awaelchli awaelchli added bug Something isn't working logger: neptune community This PR is from the community labels Dec 13, 2023
@awaelchli awaelchli added this to the 2.1.x milestone Dec 13, 2023
Comment on lines +42 to +43
_NEPTUNE_AVAILABLE = bool(RequirementCache("neptune>=1.0")) or bool(RequirementCache("neptune-client>=1.0"))
_LEGACY_NEPTUNE_CLIENT_AVAILABLE = bool(RequirementCache("neptune-client<1.0"))
Copy link
Contributor

Choose a reason for hiding this comment

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

These shouldn't be converted to bools. This class overrides str providing a helpful error message to the users. See for instance the use in L227

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_NEPTUNE_AVAILABLE = bool(RequirementCache("neptune>=1.0")) or bool(RequirementCache("neptune-client>=1.0"))
_LEGACY_NEPTUNE_CLIENT_AVAILABLE = bool(RequirementCache("neptune-client<1.0"))
_NEPTUNE_AVAILABLE = RequirementCache("neptune>=1.0") or RequirementCache("neptune-client>=1.0")
_LEGACY_NEPTUNE_CLIENT_AVAILABLE = RequirementCache("neptune-client<1.0")

Copy link
Contributor

Choose a reason for hiding this comment

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

@Raalsky What's the issue with having two separate variables each pointing to each class? (as in the current version)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These shouldn't be converted to bools. This class overrides str providing a helpful error message to the users. See for instance the use in L227

I've been trying during the development and I remember that this leads to two separate messages about the lack of one of the packages. The expected behavior is to raise/warn whenever none of neptune-client/ neptune was installed. This should be covered in: https://github.com/Lightning-AI/pytorch-lightning/pull/19131/files#diff-903c2ecc76f95d71b3f577baf15c47f0e629f6e2a4b201a344177e7908cfccd9R323

What's the issue with having two separate variables each pointing to each class? (as in the current version)

neptune was introduced as a name transition of neptune-client and the long-term target is to get rid of Neptune-client package completely someday. It was introduced as a part of breaking-changes with a release of neptune-client==1.0. neptune-client>=1.0 is just an alias of neptune package and have some breaking-changes in compare to neptune-client<1.0.0. We would like to still support all of the possible environments and package versions. The earlier approach was just "wrong" and had some misunderstandings of how the relationships between each of the packages looked like.

Copy link
Contributor

@carmocca carmocca Dec 18, 2023

Choose a reason for hiding this comment

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

If that's the motivation, then this should work (see the suggestions posted too):

_NEPTUNE_AVAILABLE = RequirementCache("neptune>=1.0")
# neptune-client will be gone someday. additionally, version 1.0 had breaking changes to account for
_NEPTUNE_CLIENT_AVAILABLE = RequirementCache("neptune-client>=1.0")
_LEGACY_NEPTUNE_CLIENT_AVAILABLE = RequirementCache("neptune-client<1.0")
_NEPTUNE_GREATER_EQUAL_1_0 = bool(_NEPTUNE_AVAILABLE or _NEPTUNE_CLIENT_AVAILABLE)

Copy link
Member

Choose a reason for hiding this comment

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

@Raalsky thank you for your explanation. As we discontinued support also for older Torch version lest make the cut also here and since next feature release work neptune package only

Comment on lines +42 to +43
_NEPTUNE_AVAILABLE = bool(RequirementCache("neptune>=1.0")) or bool(RequirementCache("neptune-client>=1.0"))
_LEGACY_NEPTUNE_CLIENT_AVAILABLE = bool(RequirementCache("neptune-client<1.0"))
Copy link
Contributor

@carmocca carmocca Dec 18, 2023

Choose a reason for hiding this comment

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

If that's the motivation, then this should work (see the suggestions posted too):

_NEPTUNE_AVAILABLE = RequirementCache("neptune>=1.0")
# neptune-client will be gone someday. additionally, version 1.0 had breaking changes to account for
_NEPTUNE_CLIENT_AVAILABLE = RequirementCache("neptune-client>=1.0")
_LEGACY_NEPTUNE_CLIENT_AVAILABLE = RequirementCache("neptune-client<1.0")
_NEPTUNE_GREATER_EQUAL_1_0 = bool(_NEPTUNE_AVAILABLE or _NEPTUNE_CLIENT_AVAILABLE)

@@ -223,7 +223,7 @@ def __init__(
prefix: str = "training",
**neptune_run_kwargs: Any,
):
if not _NEPTUNE_AVAILABLE and not _NEPTUNE_CLIENT_AVAILABLE:
if not _NEPTUNE_AVAILABLE and not _LEGACY_NEPTUNE_CLIENT_AVAILABLE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if not _NEPTUNE_AVAILABLE and not _LEGACY_NEPTUNE_CLIENT_AVAILABLE:
if not _NEPTUNE_AVAILABLE and not _NEPTUNE_CLIENT_AVAILABLE and not _LEGACY_NEPTUNE_CLIENT_AVAILABLE:

note how the str(_NEPTUNE_AVAILABLE) below is kept, so that it is suggested to install neptune>=1.0

@@ -319,6 +319,9 @@ def _verify_input_arguments(
if run is not None and not isinstance(run, (Run, Handler)):
raise ValueError("Run parameter expected to be of type `neptune.Run`, or `neptune.handler.Handler`.")

if isinstance(run, Handler) and not _NEPTUNE_AVAILABLE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Now, in all the places that currently check for _NEPTUNE_AVAILABLE, now you check _NEPTUNE_GREATER_EQUAL_1_0

because if I understood the motivation correctly, you don't care about neptune vs neptune-client but neptune<1.0 vs neptune>=1.0

@@ -335,12 +338,12 @@ def __getstate__(self) -> Dict[str, Any]:

def __setstate__(self, state: Dict[str, Any]) -> None:
if _NEPTUNE_AVAILABLE:
Copy link
Member

Choose a reason for hiding this comment

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

this seems strange import Neptune even Neptune is not available...

@@ -376,12 +379,12 @@ def training_step(self, batch, batch_idx):
@rank_zero_experiment
def run(self) -> "Run":
if _NEPTUNE_AVAILABLE:
Copy link
Member

Choose a reason for hiding this comment

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

Please use a better, more desriptive name, as it is not about Neptune but version...

@Borda
Copy link
Member

Borda commented Jan 10, 2024

let's update or rebase after #19265 lands 🎏

Copy link

gitguardian bot commented Jan 16, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
- Generic High Entropy Secret 78fa3af tests/tests_app/utilities/test_login.py View secret
- Base64 Basic Authentication 78fa3af tests/tests_app/utilities/test_login.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@awaelchli awaelchli modified the milestones: 2.1.x, 2.2.x Feb 8, 2024
@Raalsky
Copy link
Contributor Author

Raalsky commented Feb 16, 2024

Closing in favor of #19265

@Raalsky Raalsky closed this Feb 16, 2024
@Raalsky Raalsky deleted the bugfix/neptune-logger-versions-support branch February 16, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community This PR is from the community has conflicts logger: neptune pl Generic label for PyTorch Lightning package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot find neptune.new.utils with Neptune-client==0.16.3
5 participants