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

Fork Sync: Update from parent repository #1

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
"avatar_url": "https://avatars.githubusercontent.com/u/123608862?v=4",
"profile": "https://github.com/MoH-assan",
"contributions": ["bug"]
},
{
"login": "CedricLeon",
"name": "Cedric Leonard",
"avatar_url": "https://avatars.githubusercontent.com/u/51703091?v=4",
"profile": "https://github.com/CedricLeon",
"contributions": ["code", "bug"]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Check products
run: pipx run twine check dist/*

- uses: pypa/[email protected].12
- uses: pypa/[email protected].14
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to generate this and set it in "GitHub Secrets"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
run: |
pytest
- name: Upload coverage report
uses: codecov/codecov-action@v4.1.0
uses: codecov/codecov-action@v4.4.1
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.4.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.4.2
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -20,11 +20,11 @@ repos:
exclude: '.*\.ipynb'
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
rev: "v1.10.0"
hooks:
- id: mypy
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- id: codespell
args: ["-I", "codespell.txt"]
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.2.2 (21.03.2024)

### Fixed

- Switched to modern way of importing pytorch lightning (issue #96, PR #96, #97)

### Changed

- When installed with the `lightnign` optional dependency, `lightning` is installed
instead of `pytorch-lightning`

## 1.2.1 (02.02.2024)

### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Bug reports and pull requests are credited with the help of the [allcontributors
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/barthelemymp"><img src="https://avatars.githubusercontent.com/u/36533835?v=4?s=100" width="100px;" alt="Barthelemy Meynard-Piganeau"/><br /><sub><b>Barthelemy Meynard-Piganeau</b></sub></a><br /><a href="https://github.com/klieret/wandb-offline-sync-hook/issues?q=author%3Abarthelemymp" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MoH-assan"><img src="https://avatars.githubusercontent.com/u/123608862?v=4?s=100" width="100px;" alt="MoH-assan"/><br /><sub><b>MoH-assan</b></sub></a><br /><a href="https://github.com/klieret/wandb-offline-sync-hook/issues?q=author%3AMoH-assan" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/CedricLeon"><img src="https://avatars.githubusercontent.com/u/51703091?v=4?s=100" width="100px;" alt="Cedric Leonard"/><br /><sub><b>Cedric Leonard</b></sub></a><br /><a href="https://github.com/klieret/wandb-offline-sync-hook/commits?author=CedricLeon" title="Code">💻</a> <a href="https://github.com/klieret/wandb-offline-sync-hook/issues?q=author%3ACedricLeon" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = wandb_osh
version = 1.2.1
version = 1.2.2
description = Trigger wandb offline syncs from a compute node without internet
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -46,7 +46,7 @@ console_scripts =

[options.extras_require]
lightning =
pytorch-lightning
lightning
ray =
ray[tune]
testing =
Expand Down
26 changes: 19 additions & 7 deletions src/wandb_osh/lightning_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@

from os import PathLike

from pytorch_lightning import LightningModule, Trainer
from pytorch_lightning.callbacks import Callback

from wandb_osh.hooks import TriggerWandbSyncHook, _comm_default_dir
from wandb_osh.util.log import logger


# See #96
# Possible additional issues: If both imports are working, the wrong one might be used.
try:
# This is the modern way
import lightning.pytorch as pl
except ImportError:
import pytorch_lightning as pl

logger.warning(
"Imported lightning the legacy way (import pytorch_lightning as pl). "
"For more information see https://github.com/klieret/wandb-offline-sync-hook/issues/96"
)


class TriggerWandbSyncLightningCallback(Callback):
class TriggerWandbSyncLightningCallback(pl.Callback):
def __init__(
self,
communication_dir: PathLike = _comm_default_dir,
):
"""Hook to be used when interfacing wandb with pytorch lightning.
"""Hook to be used when interfacing wandb with Lightning.

Args:
communication_dir: Directory used for communication with wandb-osh.
Expand All @@ -32,8 +44,8 @@ def __init__(

def on_validation_epoch_end(
self,
trainer: Trainer,
pl_module: LightningModule,
trainer: pl.Trainer,
pl_module: pl.LightningModule,
) -> None:
if trainer.sanity_checking:
return
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lightning_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
import wandb

_ray = pytest.importorskip("pytorch_lightning")
_ray = pytest.importorskip("lightning")

from wandb_osh.lightning_hooks import TriggerWandbSyncLightningCallback # noqa: E402

Expand Down