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

update requirement for neptune #62

Merged
merged 40 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a850344
update requirement for neptune
AleksanderWWW Feb 28, 2023
10c49a2
move neptune to optional dev requirements
AleksanderWWW Mar 9, 2023
d15c57d
handle case when neptune not installed
AleksanderWWW Mar 9, 2023
4d00428
fix imports
AleksanderWWW Mar 9, 2023
e279423
update changlog
AleksanderWWW Mar 9, 2023
2d6b71f
temporarily remove macos tests
AleksanderWWW Mar 9, 2023
d814866
fix accidental typo
AleksanderWWW Mar 9, 2023
2f4b9ef
temporarily disable parallel test
AleksanderWWW Mar 9, 2023
9bdecf5
change checkout action to v3
AleksanderWWW Mar 9, 2023
2e70ce8
checkout v3 + changed neptune project
AleksanderWWW Mar 9, 2023
fb44f00
swap tests
AleksanderWWW Mar 9, 2023
bf6bf7e
experiment with dummy test
AleksanderWWW Mar 9, 2023
26a080d
uncomment and change tests
AleksanderWWW Mar 9, 2023
4c1ee8b
simplify commands
AleksanderWWW Mar 9, 2023
976bd96
change test directory
AleksanderWWW Mar 9, 2023
a442f02
fix paths, run as one test
AleksanderWWW Mar 9, 2023
898dd48
fix typo
AleksanderWWW Mar 9, 2023
c30c1af
Revert "temporarily disable parallel test"
AleksanderWWW Mar 9, 2023
9846f93
try again with no parallel
AleksanderWWW Mar 9, 2023
d2d35ee
try with max 1 parallel
AleksanderWWW Mar 9, 2023
c5e3199
check if at least one test can run
AleksanderWWW Mar 9, 2023
01d0dcb
check if after filename change still runs
AleksanderWWW Mar 9, 2023
eaa8e0c
check if assert_structure causes freeze
AleksanderWWW Mar 9, 2023
e273bf8
check if removing backoff fixes tests
AleksanderWWW Mar 9, 2023
affce32
add sleep for cache to refresh
AleksanderWWW Mar 9, 2023
9021b9e
increase sleep time and sync
AleksanderWWW Mar 9, 2023
0f315a6
try with context manager and backoff
AleksanderWWW Mar 9, 2023
b287369
backoff only 1 retry
AleksanderWWW Mar 9, 2023
f417bbd
add option to pytest to not capture stdout
AleksanderWWW Mar 9, 2023
0074629
try with sleep again
AleksanderWWW Mar 9, 2023
8cb879f
temporarily disable dict comparison assertions
AleksanderWWW Mar 9, 2023
1bef7b5
peek into cwd
AleksanderWWW Mar 9, 2023
d41acd3
peek into fetched dict
AleksanderWWW Mar 9, 2023
52afeab
some ci debbuging
AleksanderWWW Mar 9, 2023
db3072f
uncomment dicts
AleksanderWWW Mar 9, 2023
52dfc44
some more debugging
AleksanderWWW Mar 9, 2023
23d845c
fix dict field
AleksanderWWW Mar 9, 2023
10bddca
uncomment dicts again
AleksanderWWW Mar 9, 2023
6c4bfbe
cleanup
AleksanderWWW Mar 9, 2023
3a1a4ab
apply review suggestions
AleksanderWWW Mar 10, 2023
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/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
strategy:
max-parallel: 4
matrix:
os: [macos-latest, ubuntu-latest]
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
with:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Test
env:
NEPTUNE_API_TOKEN: ${{ secrets.E2E_NEPTUNE_API_TOKEN }}
NEPTUNE_PROJECT: e2e-tests/integrations
NEPTUNE_PROJECT: e2e-tests/e2e
Raalsky marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/actions/e2e

publish:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## [UNRELEASED] 0.1.5
## 0.1.5

### Fixes
- Fixed some of latest `neptune-client` warning messages ([#58](https://github.com/neptune-ai/kedro-neptune/pull/58))
- Fixed failing run on latest MacOS 12 ([#58](https://github.com/neptune-ai/kedro-neptune/pull/58))

### Changes
- Removed `neptune` and `neptune-client` from base requirements for backward compatibility ([#62](https://github.com/neptune-ai/kedro-neptune/pull/62))
- Simplified example project and removed unrelated files ([#58](https://github.com/neptune-ai/kedro-neptune/pull/58))
- Better life-time of the internally created Run in `NeptuneRunDataSet` ([#58](https://github.com/neptune-ai/kedro-neptune/pull/58))
- Updated the integration for compatibility with `neptune-client` `1.0.0`. ([#59](https://github.com/neptune-ai/kedro-neptune/pull/59))
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ python = "^3.7"
importlib-metadata = { version = "*", python = "<3.8" }

# Base requirements
neptune-client = ">=0.16.17"
kedro = ">=0.18.0"
"ruamel.yaml" = "^0.17.0"

# dev
pre-commit = { version = "*", optional = true }
pytest = { version = ">=5.0", optional = true }
pytest-cov = { version = "2.10.1", optional = true }
backoff = { version = "*", optional = true }
neptune = { version = ">=1.0.0", optional = true }

[tool.poetry.extras]
dev = [
"pre-commit",
"pytest",
"pytest-cov",
"backoff",
"neptune",
]

[tool.poetry]
Expand Down
14 changes: 7 additions & 7 deletions src/kedro_neptune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
from kedro_neptune.version import __version__

try:
# neptune-client=0.9.0+ package structure
import neptune.new as neptune
from neptune.new.handler import Handler
from neptune.new.integrations.utils import join_paths
from neptune.new.types import File
from neptune.new.utils import stringify_unsupported
except ImportError:
# neptune-client>=1.0.0 package structure
import neptune
from neptune.handler import Handler
from neptune.integrations.utils import join_paths
from neptune.types import File
from neptune.utils import stringify_unsupported
except ImportError:
# neptune-client=0.9.0+ package structure
import neptune.new as neptune
from neptune.new.handler import Handler
from neptune.new.integrations.utils import join_paths
from neptune.new.types import File
from neptune.new.utils import stringify_unsupported

INTEGRATION_VERSION_KEY = "source_code/integrations/kedro-neptune"

Expand Down
11 changes: 11 additions & 0 deletions src/kedro_neptune/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__all__ = ["__version__"]

import sys
from importlib.util import find_spec

if sys.version_info >= (3, 8):
from importlib.metadata import (
Expand All @@ -13,6 +14,16 @@
version,
)

if not (find_spec("neptune") or find_spec("neptune-client")):
msg = """
The Neptune client library was not found.

Install the neptune package with
`pip install neptune`

Need help? -> https://docs.neptune.ai/setup/installation/"""
raise PackageNotFoundError(msg)

try:
__version__ = version("kedro-neptune")
except PackageNotFoundError:
Expand Down
181 changes: 98 additions & 83 deletions tests/kedro_neptune/utils/run_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,99 +17,114 @@

import hashlib
import os
import time
from ast import literal_eval
from typing import (
List,
Optional,
)

import backoff
from neptune.new import init_run
from neptune.new.metadata_containers import Run
try:
from neptune import (
Run,
init_run,
)
except ImportError:
from neptune.new import init_run
from neptune.new.metadata_containers import Run


# It may take some time to refresh cache
@backoff.on_exception(backoff.expo, AssertionError, max_value=10)
# @backoff.on_exception(backoff.expo, AssertionError, max_value=1, max_time=60)
def assert_structure(travel_speed: int = 10000):
run = restore_run()

# Base run information
assert run.exists("kedro")
assert run.exists("kedro/catalog")
assert run.exists("kedro/nodes")
assert run.exists("kedro/kedro_command")
assert run.exists("kedro/run_params")
assert run.exists("kedro/structure")

# Data catalog
assert run.exists("kedro/catalog/datasets")
assert run.exists("kedro/catalog/files")
assert run.exists("kedro/catalog/parameters")

assert run.exists("kedro/catalog/datasets/planets")
assert run["kedro/catalog/datasets/planets"].fetch() == {
"filepath": f"{os.getcwd()}/data/planets/planets.csv",
"name": "planets",
"protocol": "file",
"save_args": {"index": False},
"type": "CSVDataSet",
"version": "None",
}

assert run.exists("kedro/catalog/datasets/planets@neptune")
assert run["kedro/catalog/datasets/planets@neptune"].fetch() == {
"extension": "csv",
"filepath": f"{os.getcwd()}/data/planets/planets.csv",
"name": "planets@neptune",
"protocol": "file",
"type": "NeptuneFileDataSet",
"version": "None",
}
assert run.exists("kedro/catalog/files/planets@neptune")
run["kedro/catalog/files/planets@neptune"].download("/tmp/file")
with open("/tmp/file", "rb") as handler:
file_content = handler.read()
assert hashlib.md5(file_content).hexdigest() == "af37712c8c80afc9690e4b70b7a590c5"

assert run.exists("kedro/catalog/files/logo")
run["kedro/catalog/files/logo"].download("/tmp/file")
with open("/tmp/file", "rb") as handler:
file_content = handler.read()
assert hashlib.md5(file_content).hexdigest() == "85d289d3ed3f321557b6c428b7b35a67"

assert run.exists("kedro/catalog/parameters/travel_speed")
assert run["kedro/catalog/parameters/travel_speed"].fetch() == travel_speed

# Nodes data
check_node_metadata(
run=run, node_namespace="kedro/nodes/distances", inputs=["planets"], outputs=["distances_to_planets"]
)
check_node_metadata(
run=run,
node_namespace="kedro/nodes/furthest",
inputs=["distances_to_planets"],
outputs=["furthest_planet_distance", "furthest_planet_name"],
)
check_node_metadata(run=run, node_namespace="kedro/nodes/judge_model", inputs=["neptune_run", "dataset"])
check_node_metadata(run=run, node_namespace="kedro/nodes/prepare_dataset", inputs=["planets"], outputs=["dataset"])
check_node_metadata(
run=run,
node_namespace="kedro/nodes/travel_time",
inputs=["furthest_planet_distance", "furthest_planet_name", "params:travel_speed"],
outputs=["travel_hours"],
)
assert run.exists("kedro/nodes/travel_time/parameters")
assert run.exists("kedro/nodes/travel_time/parameters/travel_speed")
assert run["kedro/nodes/travel_time/parameters/travel_speed"].fetch() == travel_speed

# User defined data
assert run.exists("furthest_planet")
assert run.exists("furthest_planet/name")
assert run.exists("furthest_planet/travel_days")
assert run.exists("furthest_planet/travel_hours")
assert run.exists("furthest_planet/travel_months")
assert run.exists("furthest_planet/travel_years")
assert run["furthest_planet/name"].fetch() == "NEPTUNE"
time.sleep(30)
with init_run(
Raalsky marked this conversation as resolved.
Show resolved Hide resolved
capture_stderr=False,
capture_stdout=False,
capture_hardware_metrics=False,
capture_traceback=False,
source_files=[],
) as run:
run.sync(wait=True)
# Base run information
assert run.exists("kedro")
assert run.exists("kedro/catalog")
assert run.exists("kedro/nodes")
assert run.exists("kedro/kedro_command")
assert run.exists("kedro/run_params")
assert run.exists("kedro/structure")

# Data catalog
assert run.exists("kedro/catalog/datasets")
assert run.exists("kedro/catalog/files")
assert run.exists("kedro/catalog/parameters")

assert run.exists("kedro/catalog/datasets/planets")

assert run["kedro/catalog/datasets/planets"].fetch() == {
"filepath": f"{os.getcwd()}/data/planets/planets.csv",
"name": "planets",
"save_args": {"index": False},
"type": "CSVDataSet",
"version": "None",
}

assert run.exists("kedro/catalog/datasets/planets@neptune")
assert run["kedro/catalog/datasets/planets@neptune"].fetch() == {
"extension": "csv",
"filepath": f"{os.getcwd()}/data/planets/planets.csv",
"name": "planets@neptune",
"protocol": "file",
"type": "NeptuneFileDataSet",
"version": "None",
}
assert run.exists("kedro/catalog/files/planets@neptune")
run["kedro/catalog/files/planets@neptune"].download("/tmp/file")
with open("/tmp/file", "rb") as handler:
file_content = handler.read()
assert hashlib.md5(file_content).hexdigest() == "af37712c8c80afc9690e4b70b7a590c5"

assert run.exists("kedro/catalog/files/logo")
run["kedro/catalog/files/logo"].download("/tmp/file")
with open("/tmp/file", "rb") as handler:
file_content = handler.read()
assert hashlib.md5(file_content).hexdigest() == "85d289d3ed3f321557b6c428b7b35a67"

assert run.exists("kedro/catalog/parameters/travel_speed")
assert run["kedro/catalog/parameters/travel_speed"].fetch() == travel_speed

# Nodes data
check_node_metadata(
run=run, node_namespace="kedro/nodes/distances", inputs=["planets"], outputs=["distances_to_planets"]
)
check_node_metadata(
run=run,
node_namespace="kedro/nodes/furthest",
inputs=["distances_to_planets"],
outputs=["furthest_planet_distance", "furthest_planet_name"],
)
check_node_metadata(run=run, node_namespace="kedro/nodes/judge_model", inputs=["neptune_run", "dataset"])
check_node_metadata(
run=run, node_namespace="kedro/nodes/prepare_dataset", inputs=["planets"], outputs=["dataset"]
)
check_node_metadata(
run=run,
node_namespace="kedro/nodes/travel_time",
inputs=["furthest_planet_distance", "furthest_planet_name", "params:travel_speed"],
outputs=["travel_hours"],
)
assert run.exists("kedro/nodes/travel_time/parameters")
assert run.exists("kedro/nodes/travel_time/parameters/travel_speed")
assert run["kedro/nodes/travel_time/parameters/travel_speed"].fetch() == travel_speed

# User defined data
assert run.exists("furthest_planet")
assert run.exists("furthest_planet/name")
assert run.exists("furthest_planet/travel_days")
assert run.exists("furthest_planet/travel_hours")
assert run.exists("furthest_planet/travel_months")
assert run.exists("furthest_planet/travel_years")
assert run["furthest_planet/name"].fetch() == "NEPTUNE"


def restore_run():
Expand Down