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

Misc adjustments to dependency tracking #1389

Merged
merged 1 commit into from Jul 6, 2023

Conversation

AleksanderWWW
Copy link
Contributor

@AleksanderWWW AleksanderWWW commented Jul 4, 2023

Before submitting checklist

  • Did you update the CHANGELOG? (not for test updates, internal changes/refactors or CI/CD setup)
  • Did you ask the docs owner to review all the user-facing changes?

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Patch coverage: 91.66% and project coverage change: -6.37 ⚠️

Comparison is base (b1bedc9) 79.53% compared to head (c382900) 73.17%.

❗ Current head c382900 differs from pull request most recent head ae5a6ce. Consider uploading reports for the commit ae5a6ce to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1389      +/-   ##
==========================================
- Coverage   79.53%   73.17%   -6.37%     
==========================================
  Files         279      279              
  Lines       13849    13562     -287     
==========================================
- Hits        11015     9924    -1091     
- Misses       2834     3638     +804     
Flag Coverage Δ
e2e ?
e2e- ?
e2e-management ?
e2e-s3 ?
e2e-s3-gcs ?
e2e-standard ?
macos 72.87% <91.66%> (-6.41%) ⬇️
macos-latest ?
py3.10 ?
py3.7 73.17% <91.66%> (-5.84%) ⬇️
py3.7.16 ?
py3.8 ?
py3.9 ?
ubuntu 73.02% <91.66%> (-6.29%) ⬇️
ubuntu-latest ?
unit 73.17% <91.66%> (-0.58%) ⬇️
windows 72.31% <91.66%> (-7.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/neptune/internal/utils/dependency_tracking.py 90.90% <91.66%> (+4.70%) ⬆️

... and 106 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -4,10 +4,10 @@
"FileDependenciesStrategy",
]

import logging
Copy link
Contributor

Choose a reason for hiding this comment

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

We have our custom logger somewhere. It has some settings to simplify filtering etc. I think it's:

from neptune.internal.utils.logger import logger

@@ -32,7 +32,9 @@ def log_dependencies(self, run: "Run") -> None:
class InferDependenciesStrategy(DependencyTrackingStrategy):
def log_dependencies(self, run: "Run") -> None:
try:
dependencies_str = subprocess.check_output([sys.executable, "-m", "pip", "freeze"]).decode("utf-8")
dependencies_str = subprocess.check_output([sys.executable, "-m", "pip", "list", "--format=freeze"]).decode(
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried the importlib approach? I've been suggesting something like:

import sys

if sys.version_info >= (3, 8):
    from importlib.metadata import distributions
else:
    from importlib_metadata import distributions


def list_installed_packages():
    dists = list(sorted(distributions(), key=lambda d: d.metadata['Name']))

    for dist in dists:
        name, version = dist.metadata['Name'], dist.metadata['Version']
        print(f'{name}=={version}')


def main():
    list_installed_packages()


if __name__ == '__main__':
    main()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Just tried. This seems to work very well!

Lets do this instead of subprocess

log and error instead of warning if path does not exist

upload as file, not file set

remove warning test case

adjust unit tests

test if error was logged with non existent file

adjust units

update changelog

update changelog

use neptune logger instead of logging.error

use importlib instead of subprocess
@AleksanderWWW AleksanderWWW merged commit 53d6ce4 into master Jul 6, 2023
4 checks passed
@AleksanderWWW AleksanderWWW deleted the aw/dep-tracking-pip-list branch July 6, 2023 09:22

### Changes
- Dependency tracking feature will log an error if a given file path doesn't exist ([#1389](https://github.com/neptune-ai/neptune-client/pull/1389))
- Use `pip list --format=freeze` instead of `pip freeze` in dependency tracking ([#1389](https://github.com/neptune-ai/neptune-client/pull/1389))
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it was fixed, but this note is misleading as we're not using it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@twolodzko @SiddhantSadangi I'm addressing this by the way in this PR: #1391

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