-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from zincware/development
ZnTrack [0.1.5]
- Loading branch information
Showing
17 changed files
with
30,915 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Check black coding style | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- development | ||
pull_request: | ||
branches: | ||
- main | ||
- development | ||
|
||
jobs: | ||
doc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Black Check | ||
uses: psf/black@stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
This program and the accompanying materials are made available under the terms of the | ||
Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
https://www.eclipse.org/legal/epl-v20.html | ||
SPDX-License-Identifier: EPL-2.0 | ||
Copyright Contributors to the Zincware Project. | ||
Description: | ||
""" | ||
import subprocess | ||
|
||
from zntrack import Node, dvc | ||
from pathlib import Path | ||
import json | ||
import shutil | ||
import os | ||
|
||
|
||
@Node() | ||
class ComputeMeaning: | ||
"""BasicTest class""" | ||
|
||
metric: Path = dvc.metrics(Path("my_metric.json")) | ||
|
||
def run(self): | ||
"""Run method of the Node test instance""" | ||
self.metric.write_text(json.dumps({"val1": 42})) | ||
|
||
|
||
@Node() | ||
class PrintMeaning: | ||
computation: ComputeMeaning = dvc.deps(ComputeMeaning(load=True)) | ||
|
||
def run(self): | ||
print(self.computation.metric.read_text()) | ||
|
||
|
||
def test_project(tmp_path): | ||
"""Check that metric files are added to the dependencies when depending on a Node""" | ||
shutil.copy(__file__, tmp_path) | ||
os.chdir(tmp_path) | ||
subprocess.check_call(["git", "init"]) | ||
subprocess.check_call(["dvc", "init"]) | ||
|
||
ComputeMeaning()() | ||
PrintMeaning()() | ||
|
||
subprocess.check_call(["dvc", "repro"]) | ||
|
||
print_meaning = PrintMeaning(load=True) | ||
print_meaning.zntrack.update_dvc() | ||
|
||
assert ComputeMeaning(load=True).metric in print_meaning.zntrack.dvc.deps | ||
assert ( | ||
ComputeMeaning(load=True).zntrack.dvc.json_file | ||
in print_meaning.zntrack.dvc.deps | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
This program and the accompanying materials are made available under the terms of the | ||
Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
https://www.eclipse.org/legal/epl-v20.html | ||
SPDX-License-Identifier: EPL-2.0 | ||
Copyright Contributors to the Zincware Project. | ||
Description: | ||
""" | ||
import pytest | ||
from zntrack import Node | ||
import os | ||
|
||
|
||
@Node() | ||
class HelloWorld: | ||
def run(self): | ||
pass | ||
|
||
|
||
def test_pre_call(tmp_path): | ||
"""Check, that calling a loaded Node raises an error""" | ||
os.chdir(tmp_path) | ||
|
||
hello_world = HelloWorld(load=True) | ||
|
||
with pytest.raises(ValueError): | ||
hello_world() |
Oops, something went wrong.