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

Lightning 3.0 updates #727

Merged
merged 5 commits into from
Oct 21, 2023
Merged

Lightning 3.0 updates #727

merged 5 commits into from
Oct 21, 2023

Conversation

dberenbaum
Copy link
Collaborator

@dberenbaum dberenbaum commented Oct 18, 2023

Fixes #726

Update lightning logger kwargs to reflect dvclive 3.0 updates and other missed changes

@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2023

Codecov Report

Attention: 34 lines in your changes are missing coverage. Please review.

Files Coverage Δ
src/dvclive/lightning.py 0.00% <0.00%> (ø)
tests/frameworks/test_lightning.py 7.14% <11.11%> (+1.08%) ⬆️

📢 Thoughts on this report? Let us know!.

@dberenbaum dberenbaum requested review from a team and shcheklein October 19, 2023 18:57
@dberenbaum dberenbaum marked this pull request as ready for review October 19, 2023 18:57
dir: Optional[str] = None, # noqa: A002
resume: bool = False,
report: Optional[str] = None,
save_dvc_exp: bool = False,
dvcyaml: bool = True,
cache_images: bool = False,
**kwargs,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explicit kwargs initially came from #178. This is no longer an issue in newer versions of lightning, and there are CLI tests already in lightning that I added below.

Comment on lines +306 to +329
# LightningCLI tests
# Copied from https://github.com/Lightning-AI/lightning/blob/e7afe04ee86b64c76a5446088b3b75d9c275e5bf/tests/tests_pytorch/test_cli.py
class TestModel(BoringModel):
def __init__(self, foo, bar=5):
super().__init__()
self.foo = foo
self.bar = bar


def _test_logger_init_args(logger_name, init, unresolved={}): # noqa: B006
cli_args = [f"--trainer.logger={logger_name}"]
cli_args += [f"--trainer.logger.{k}={v}" for k, v in init.items()]
cli_args += [f"--trainer.logger.dict_kwargs.{k}={v}" for k, v in unresolved.items()]
cli_args.append("--print_config")

out = StringIO()
with mock.patch(
"sys.argv", ["any.py"] + cli_args # noqa: RUF005
), redirect_stdout( # noqa: RUF100
out
), pytest.raises(
SystemExit
):
LightningCLI(TestModel, run=False)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Once we move this whole integration to lightning, we won't have to copy all this from lightning tests.

@dberenbaum
Copy link
Collaborator Author

Tests are failing because of an issue with pip cache? Don't know if it's related to the PR.

@shcheklein
Copy link
Member

shcheklein commented Oct 20, 2023

I've cleaned up the cache in Actions -> Cached (there was one for 3.7GB !) and reran it.

}
if dir is not None:
self._live_init["dir"] = dir
self._live_init: Dict[str, Any] = kwargs
Copy link
Member

Choose a reason for hiding this comment

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

double check:

  • default values in kwargs, e.g. will we still consider dvcyaml as True if it's not specified in kwargs
  • might worth creating copy of kwargs, so that we 100% that's it's frozen for the external world

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added tests for both of those cases. With the test, I didn't think it's necessary to make a copy of kwargs, and I don't see it happening in other loggers like https://github.com/Lightning-AI/lightning/blob/master/src/lightning/pytorch/loggers/comet.py, but not that strong an opinion if you really feel it's necessary.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, I think we overdid this :) kwargs creates a new dict object when it's being passed I think we don't need a test (no need to test Python I guess :) ). I was asking primarily to check that tbh

same with default values, if it's Python behavior - no need to test this

Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

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

Thanks, @dberenbaum ! I've reviewed it quickly.

@dberenbaum dberenbaum requested a review from shcheklein October 21, 2023 12:58
@dberenbaum dberenbaum merged commit a488e83 into main Oct 21, 2023
15 of 20 checks passed
@dberenbaum dberenbaum deleted the lightning-3.0 branch October 21, 2023 19:57
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.

lightning: args passed to dvclive are outdated
3 participants