Skip to content

Commit

Permalink
Added imports test (#777)
Browse files Browse the repository at this point in the history
* Added imports test

* Year

* management internal removed

* Disabled linte

* Fixed to 0.13.0 version

* Temporary deleted

* Addded fixed to 0.13.0 version

* Added dev script

* Fixed black

* Linter

* Fixed backward compatibility of imports

* CHANGELOG updated
  • Loading branch information
Raalsky authored Dec 14, 2021
1 parent 01dabff commit 098f3a5
Show file tree
Hide file tree
Showing 5 changed files with 627 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
## neptune-client 0.13.5
## [UNRELEASED] neptune-client 0.13.5

### Fixes
- Restore RunMode for backward compatibility ([#775](https://github.com/neptune-ai/neptune-client/pull/775));
- Restore RunMode for backward compatibility ([#775](https://github.com/neptune-ai/neptune-client/pull/775))
- Restore imports for backward compatibility ([#777](https://github.com/neptune-ai/neptune-client/pull/777))

## neptune-client 0.13.4

### Fixes
- Fix issue that prevented waiting for subprocesses to finish after receiving stop signal from backend ([#774](https://github.com/neptune-ai/neptune-client/pull/774));
- Fix issue that prevented waiting for subprocesses to finish after receiving stop signal from backend ([#774](https://github.com/neptune-ai/neptune-client/pull/774))
Timeout now overridable using environment var `NEPTUNE_SUBPROCESS_KILL_TIMEOUT`

## neptune-client 0.13.3
Expand Down
79 changes: 79 additions & 0 deletions dev_tools/prepare_test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# Copyright (c) 2021, 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
#
import pkgutil
import inspect
import importlib

EXCLUDED_MODULES = [
"neptune.internal",
"neptune.new.internal",
"neptune.vendor.pynvml",
"neptune.management.internal",
]


def extract_module_classes(module_name: str):
for module_info in pkgutil.iter_modules([module_name]):
if module_info.name.startswith("_"):
continue

if module_info.ispkg:
for module_dotted, classname in extract_module_classes(
f"{module_name}/{module_info.name}"
):
yield (module_dotted, classname)
else:
module_dotted = module_name.replace("/", ".") + "." + module_info.name
# print(module_dotted)
module = importlib.import_module(module_dotted)
for classname, _ in inspect.getmembers(module, inspect.isclass):
yield (module_dotted, classname)


if __name__ == "__main__":
print(
"""#
# Copyright (c) 2021, 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.
#
# pylint: disable=unused-import,reimported,import-error,no-name-in-module
import unittest
"""
)
for module_name, classname in sorted(list(extract_module_classes("neptune"))):
excluded = False

for excluded_module in EXCLUDED_MODULES:
if module_name.startswith(excluded_module):
excluded = True
break

if not excluded:
print("from", module_name, "import", classname)

print(
"""
class TestImports(unittest.TestCase):
def test_imports(self):
pass"""
)
2 changes: 2 additions & 0 deletions neptune/new/attributes/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
if TYPE_CHECKING:
from neptune.new.attribute_container import AttributeContainer

RunStructure = ContainerStructure # backwards compatibility


class Namespace(Attribute, MutableMapping):
def __init__(self, container: "AttributeContainer", path: List[str]):
Expand Down
37 changes: 36 additions & 1 deletion neptune/new/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,42 @@
)
from neptune.new.internal.state import ContainerState

RunState = ContainerState # backwards compatibility
# backwards compatibility
# pylint: disable=unused-import
from neptune.new.attributes.attribute import Attribute
from neptune.new.attributes.namespace import (
NamespaceBuilder,
Namespace as NamespaceAttr,
)
from neptune.new.exceptions import (
MetadataInconsistency,
InactiveRunException,
NeptunePossibleLegacyUsageException,
)
from neptune.new.handler import Handler
from neptune.new.internal.backends.api_model import AttributeType
from neptune.new.internal.operation import DeleteAttribute
from neptune.new.internal.run_structure import ContainerStructure as RunStructure
from neptune.new.internal.utils import (
is_bool,
is_float,
is_float_like,
is_int,
is_string,
is_string_like,
verify_type,
is_dict_like,
)
from neptune.new.internal.utils.paths import parse_path
from neptune.new.internal.value_to_attribute_visitor import ValueToAttributeVisitor
from neptune.new.types import Boolean, Integer
from neptune.new.types.atoms.datetime import Datetime
from neptune.new.types.atoms.float import Float
from neptune.new.types.atoms.string import String
from neptune.new.types.namespace import Namespace
from neptune.new.types.value import Value

RunState = ContainerState


class Run(AttributeContainer):
Expand Down
Loading

0 comments on commit 098f3a5

Please sign in to comment.