Skip to content

Commit

Permalink
move tensorflow tests to integrations (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderWWW authored May 7, 2024
1 parent 448759d commit 4e79378
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 24 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,57 @@ jobs:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.mosaicml.result }}

tensorflow-images:
env:
BUCKET_NAME: ${{ secrets.E2E_BUCKET_NAME }}
USER_USERNAME: ${{ secrets.E2E_USER_USERNAME }}
ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
ADMIN_NEPTUNE_API_TOKEN: ${{ secrets.E2E_ADMIN_NEPTUNE_API_TOKEN }}
SERVICE_ACCOUNT_NAME: ${{ secrets.E2E_SERVICE_ACCOUNT_NAME }}
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.10" ]
os: [ ubuntu-latest ]
include:
- python-version: "3.8"
os: macos-latest
runs-on: ${{ matrix.os }}
name: 'tensorflow-images (${{ matrix.os }} - py${{ matrix.python-version }})'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Test
uses: ./.github/actions/test-e2e
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
module: tensorflow
report_job: 'tensorflow-images (${{ matrix.os }} - py${{ matrix.python-version }})'
pip_url: tensorflow

tensorflow-images-notify:
needs: [ tensorflow-images ]
runs-on: ubuntu-latest
if: (success() || failure()) && github.ref == 'refs/heads/dev/1.x'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Notify
uses: ./.github/actions/job-notify
with:
slack-webhook: ${{ secrets.E2E_INTEGRATIONS_SLACK_WEBHOOK }}
job-status: ${{ needs.tensorflow-images.result }}

detectron2:
env:
NEPTUNE_PROJECT: e2e-tests/integrations
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/unit-in-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
os: [ubuntu, windows]
python-version: ["3.7"]
include:
- os: macos
python-version: "3.8"
name: 'test (${{ matrix.os }} - py${{ matrix.python-version }})'
runs-on: ${{ matrix.os }}-latest
steps:
Expand Down
1 change: 0 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ bokeh
matplotlib
seaborn
plotly
tensorflow
torch
typing_extensions>=4.6.0

Expand Down
44 changes: 44 additions & 0 deletions tests/e2e/integrations/test_tensorflow_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright (c) 2024, Neptune Labs Sp. z o.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import numpy
import pytest
import tensorflow as tf
from PIL import Image

import neptune
from neptune.types import File


@pytest.mark.integrations
@pytest.mark.tensorflow
def test_tensorflow_image_logging(environment):
# given
image_tensor = tf.random.uniform(shape=[200, 300, 3], dtype=tf.int32, maxval=5, minval=1)

# when
with neptune.Run(project=environment.project) as run:
run_id = run["sys/id"].fetch()
run["test_image"] = File.as_image(image_tensor)

run.sync()

# then
with neptune.Run(with_id=run_id, project=environment.project) as run:
run["test_image"].download()

image_fetched = Image.open("test_image.png")

assert numpy.array_equal(image_tensor.numpy(), numpy.array(image_fetched))
1 change: 1 addition & 0 deletions tests/e2e/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ markers =
huggingface: a test is testing an HuggingFace Transformers integration
zenml: a test is running zenml tests
mosaicml: a test is running mosaicml tests
tensorflow: a test is using TensorFlow
11 changes: 0 additions & 11 deletions tests/unit/neptune/legacy/internal/utils/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,3 @@ def test_get_image_content_from_torch_tensor(self):

# expect
self.assertEqual(get_image_content(image_tensor), _get_pil_image_data(expected_image))

def test_get_image_content_from_tensorflow_tensor(self):
import tensorflow as tf

# given
image_tensor = tf.random.uniform(shape=[200, 300, 3])
expected_array = image_tensor.numpy() * 255
expected_image = Image.fromarray(expected_array.astype(numpy.uint8))

# expect
self.assertEqual(get_image_content(image_tensor), _get_pil_image_data(expected_image))
11 changes: 0 additions & 11 deletions tests/unit/neptune/new/internal/utils/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@ def test_get_image_content_from_torch_tensor(self):
# and make sure that original image's size was preserved
self.assertFalse((image_tensor.numpy() * 255 - expected_array).any())

def test_get_image_content_from_tensorflow_tensor(self):
import tensorflow as tf

# given
image_tensor = tf.random.uniform(shape=[200, 300, 3])
expected_array = image_tensor.numpy() * 255
expected_image = Image.fromarray(expected_array.astype(numpy.uint8))

# expect
self.assertEqual(get_image_content(image_tensor), self._encode_pil_image(expected_image))

def test_get_image_content_from_seaborn_figure(self):
# given
grid = sns.relplot(numpy.random.randn(6, 4))
Expand Down

0 comments on commit 4e79378

Please sign in to comment.