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 support for additional seaborn images #1864

Merged
merged 14 commits into from
Oct 1, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @Raalsky, @AleksanderWWW and @szysad will be requested for
# @PatrykGala and @kgodlewski will be requested for
# review when someone opens a pull request.
/* @Raalsky @AleksanderWWW @szysad
/* @PatrykGala @kgodlewski

# File/directory specific owners
/README.md @normandy7 @Raalsky @AleksanderWWW @szysad
/README.md @normandy7 @PatrykGala @kgodlewski
4 changes: 2 additions & 2 deletions .github/neptune_client_pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ style = "semver"
pattern = "default-unprefixed"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"

# Python lack of functionalities from future versions
importlib-metadata = { version = "*", python = "<3.8" }
Expand Down Expand Up @@ -42,7 +42,7 @@ pandas = "*"

# Additional integrations
kedro-neptune = { version = "*", optional = true, python = "<3.11" }
neptune-detectron2 = { version = "*", optional = true, python = ">=3.7"}
neptune-detectron2 = { version = "*", optional = true, python = ">=3.8"}
neptune-fastai = { version = "*", optional = true }
neptune-lightgbm = { version = "*", optional = true }
pytorch-lightning = { version = "*", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.12" ]
python-version: [ "3.8", "3.12" ]
SiddhantSadangi marked this conversation as resolved.
Show resolved Hide resolved
os: [ ubuntu, windows ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.12" ]
python-version: [ "3.8", "3.12" ]
os: [ ubuntu, windows ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.12" ]
python-version: [ "3.8", "3.12" ]
os: [ ubuntu, windows ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.12" ]
python-version: [ "3.8", "3.12" ]
os: [ ubuntu, windows ]
include:
- python-version: "3.8"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
> Command | Description
> --- | ---
> /pre-commit-apply | Commit a pre-commit suggestions
> /run-unit | Run unittests on full matrix *(win, mac, linux x py3.7-3.12)
> /run-e2e | Run E2E tests on full matrix *(win, mac, linux x py3.7-3.12)
> /run-integrations | Run Client integrations on full matrix *(win, mac, linux x py3.7-3.12)
> /run-all-test | Run all tests on full matrix *(win, mac, linux x py3.7-3.12)
> /run-unit | Run unittests on full matrix *(win, mac, linux x py3.8-3.12)
> /run-e2e | Run E2E tests on full matrix *(win, mac, linux x py3.8-3.12)
> /run-integrations | Run Client integrations on full matrix *(win, mac, linux x py3.8-3.12)
> /run-all-test | Run all tests on full matrix *(win, mac, linux x py3.8-3.12)
reaction-type: hooray
16 changes: 8 additions & 8 deletions .github/workflows/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
python-version: [ "3.8", "3.10" ]
os: [ ubuntu-latest, windows-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
python-version: [ "3.8", "3.10" ]
os: [ ubuntu-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
python-version: [ "3.8", "3.10" ]
os: [ ubuntu-latest, windows-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
python-version: [ "3.8", "3.10" ]
os: [ ubuntu-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -435,7 +435,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
python-version: [ "3.8", "3.10" ]
os: [ ubuntu-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -579,7 +579,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.9" ]
python-version: [ "3.8", "3.9" ]
os: [ ubuntu-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -632,7 +632,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.9" ]
python-version: [ "3.8", "3.9" ]
os: [ ubuntu-latest, windows-latest ]
include:
- python-version: "3.8"
Expand Down Expand Up @@ -685,7 +685,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
python-version: [ "3.8", "3.10" ]
os: [ ubuntu-latest, windows-latest ]
include:
- python-version: "3.8"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-in-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, windows]
python-version: ["3.7"]
python-version: ["3.8"]
include:
- os: macos
python-version: "3.8"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu, windows]
include:
- python-version: "3.8"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## neptune 1.12.0

### Changes
- Dropped support for Python 3.7 ([#1864](https://github.com/neptune-ai/neptune-client/pull/1864))

### Fixes
- Fixed support for additional Seaborn figure types ([#1864](https://github.com/neptune-ai/neptune-client/pull/1864))

## neptune 1.11.1

### Fixes
Expand Down
5 changes: 0 additions & 5 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ flags:
- src/neptune
carryforward: true

py3.7:
paths:
- src/neptune
carryforward: true

py3.8:
paths:
- src/neptune
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ style = "semver"
pattern = "default-unprefixed"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"

# Python lack of functionalities from future versions
importlib-metadata = { version = "*", python = "<3.8" }
typing-extensions = ">=3.10.0"

# Missing compatibility layer between Python 2 and Python 3
Expand Down Expand Up @@ -43,7 +42,7 @@ pandas = "*"

# Additional integrations
kedro-neptune = { version = "*", optional = true, python = ">=3.9,<3.12" }
neptune-detectron2 = { version = "*", optional = true, python = ">=3.7"}
neptune-detectron2 = { version = "*", optional = true, python = ">=3.8"}
neptune-fastai = { version = "*", optional = true }
neptune-lightgbm = { version = "*", optional = true }
pytorch-lightning = { version = "*", optional = true }
Expand Down
4 changes: 3 additions & 1 deletion src/neptune/internal/utils/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def _get_pil_image_data(image: PILImage) -> bytes:


def _get_figure_image_data(figure) -> bytes:
if figure.__class__.__name__ == "Axes":
figure = figure.figure
with io.BytesIO() as image_buffer:
figure.savefig(image_buffer, format="png", bbox_inches="tight")
return image_buffer.getvalue()
Expand Down Expand Up @@ -283,7 +285,7 @@ def is_pil_image(image) -> bool:


def is_matplotlib_figure(image):
return image.__class__.__module__.startswith("matplotlib.") and image.__class__.__name__ == "Figure"
return image.__class__.__module__.startswith("matplotlib.") and image.__class__.__name__ in ["Figure", "Axes"]


def is_plotly_figure(chart):
Expand Down
2 changes: 2 additions & 0 deletions src/neptune/legacy/internal/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def get_image_content(image):


def _get_figure_as_image(figure):
if figure.__class__.__name__ == "Axes":
figure = figure.figure
with io.BytesIO() as image_buffer:
figure.savefig(image_buffer, format="png", bbox_inches="tight")
return image_buffer.getvalue()
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/neptune/new/internal/utils/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@


class TestImage(unittest.TestCase):

TEST_DIR = "/tmp/neptune/{}".format(uuid4())

def setUp(self):
Expand Down Expand Up @@ -143,6 +142,12 @@ def test_get_image_content_from_seaborn_figure(self):
# then
self.assertEqual(get_image_content(grid), self._encode_figure(grid))

# given
figure = sns.lineplot(x=[1, 2, 3], y=[4, 5, 6])

# then
self.assertEqual(get_image_content(figure), self._encode_figure(figure))

def test_get_html_from_matplotlib_figure(self):
# given
fig = pyplot.figure()
Expand Down Expand Up @@ -262,6 +267,8 @@ def _encode_pil_image(image: Image) -> bytes:

@staticmethod
def _encode_figure(fig: Figure) -> bytes:
if fig.__class__.__name__ == "Axes":
fig = fig.figure
with io.BytesIO() as image_buffer:
fig.savefig(image_buffer, format="PNG", bbox_inches="tight")
return image_buffer.getvalue()
Expand Down
Loading