Skip to content

Commit

Permalink
Merge pull request #96 from zincware/development
Browse files Browse the repository at this point in the history
ZnTrack [0.1.4]
  • Loading branch information
PythonFZ authored Oct 23, 2021
2 parents added31 + 45c08d5 commit 62e55b2
Show file tree
Hide file tree
Showing 26 changed files with 6,885 additions and 205 deletions.
4 changes: 2 additions & 2 deletions CI/integration_tests/test_ValueError_loading_Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Description:
"""
import pytest
from zntrack import Node, ZnTrackProject, DVC
from zntrack import Node, ZnTrackProject, dvc
import shutil
import os

Expand All @@ -18,7 +18,7 @@
class HelloWorld:
"""BasicTest class"""

output = DVC.result()
output = dvc.result()

def run(self):
"""Run method of the Node test instance"""
Expand Down
8 changes: 4 additions & 4 deletions CI/integration_tests/test_class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
from pathlib import Path
import json
import os
Expand All @@ -16,9 +16,9 @@ class BasicTest:

def __init__(self):
"""Constructor of the Node test instance"""
self.deps = DVC.deps([Path("deps1", "input.json"), Path("deps2", "input.json")])
self.parameters = DVC.params()
self.results = DVC.result()
self.deps = dvc.deps([Path("deps1", "input.json"), Path("deps2", "input.json")])
self.parameters = dvc.params()
self.results = dvc.result()

def __call__(self, **kwargs):
"""Call Method of the Node test instance"""
Expand Down
18 changes: 9 additions & 9 deletions CI/integration_tests/test_example_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os
from tempfile import TemporaryDirectory

from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
from pathlib import Path

temp_dir = TemporaryDirectory()
Expand All @@ -29,9 +29,9 @@ def __init__(self):
Definition of parameters and results
"""
self.outs = DVC.outs(Path("calculation.txt"))
self.deps = DVC.deps()
self.param = DVC.params()
self.outs = dvc.outs(Path("calculation.txt"))
self.deps = dvc.deps()
self.param = dvc.params()

def __call__(self, file):
"""User input"""
Expand All @@ -54,13 +54,13 @@ def __init__(self):
Definition of parameters and results
"""
self.outs = DVC.outs(Path("calculation.txt"))
self.outs = dvc.outs(Path("calculation.txt"))

self.n_1 = DVC.params() # seems optional now
self.n_2 = DVC.params()
self.n_1 = dvc.params() # seems optional now
self.n_2 = dvc.params()

self.sum = DVC.result()
self.dif = DVC.result()
self.sum = dvc.result()
self.dif = dvc.result()

def __call__(self, n_1, n_2):
"""User input
Expand Down
5 changes: 2 additions & 3 deletions CI/integration_tests/test_exec_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
Description:
"""
import pytest
from zntrack import Node, ZnTrackProject, DVC
from zntrack import Node, ZnTrackProject, dvc
import shutil
import os

Expand All @@ -18,7 +17,7 @@
class HelloWorld:
"""BasicTest class"""

output = DVC.result()
output = dvc.result()

def run(self):
"""Run method of the Node test instance"""
Expand Down
30 changes: 15 additions & 15 deletions CI/integration_tests/test_graph_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os
from tempfile import TemporaryDirectory

from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
import numpy as np

temp_dir = TemporaryDirectory()
Expand All @@ -27,8 +27,8 @@ class ComputeA:
"""Node stage A"""

def __init__(self):
self.inp = DVC.params()
self.out = DVC.result()
self.inp = dvc.params()
self.out = dvc.result()

def __call__(self, inp):
self.inp = inp
Expand All @@ -42,8 +42,8 @@ class ComputeB:
"""Node stage B"""

def __init__(self):
self.inp = DVC.params()
self.out = DVC.result()
self.inp = dvc.params()
self.out = dvc.result()

def __call__(self, inp):
self.inp = inp
Expand All @@ -57,11 +57,11 @@ class ComputeAB:
"""Node stage AB, depending on A&B"""

def __init__(self):
self.a = DVC.deps(ComputeA(id_=0))
self.b = DVC.deps(ComputeB(id_=0))
self.out = DVC.result()
self.a = dvc.deps(ComputeA(id_=0))
self.b = dvc.deps(ComputeB(id_=0))
self.out = dvc.result()

self.param = DVC.params()
self.param = dvc.params()

def __call__(self):
self.param = "default"
Expand All @@ -77,8 +77,8 @@ class ComputeANamed:
"""Node stage A"""

def __init__(self):
self.inp = DVC.params()
self.out = DVC.result()
self.inp = dvc.params()
self.out = dvc.result()

def __call__(self, inp):
self.inp = inp
Expand All @@ -92,11 +92,11 @@ class ComputeABNamed:
"""Node stage AB, depending on A&B with a custom stage name"""

def __init__(self):
self.a: ComputeANamed = DVC.deps(ComputeANamed(id_=0))
self.b: ComputeB = DVC.deps(ComputeB(id_=0))
self.out = DVC.result()
self.a: ComputeANamed = dvc.deps(ComputeANamed(id_=0))
self.b: ComputeB = dvc.deps(ComputeB(id_=0))
self.out = dvc.result()

self.param = DVC.params()
self.param = dvc.params()

def __call__(self):
self.param = "default"
Expand Down
20 changes: 10 additions & 10 deletions CI/integration_tests/test_multi_deps_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
Description:
"""
from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
import os
import shutil


@Node()
class CreateNumbers:
number = DVC.result()
number = dvc.result()

def run(self):
self.number = 42


@Node()
class AddOne:
inp = DVC.deps(CreateNumbers(load=True))
number = DVC.result()
inp = dvc.deps(CreateNumbers(load=True))
number = dvc.result()

def run(self):
self.number = self.inp.number + 1


@Node()
class SubtractOne:
inp = DVC.deps(CreateNumbers(load=True))
number = DVC.result()
inp = dvc.deps(CreateNumbers(load=True))
number = dvc.result()

def run(self):
self.number = self.inp.number - 1
Expand All @@ -43,8 +43,8 @@ def run(self):
class Summation:
"""Stage that is actually tested, containing the multiple dependencies"""

inp = DVC.deps([AddOne(load=True), SubtractOne(load=True)])
number = DVC.result()
inp = dvc.deps([AddOne(load=True), SubtractOne(load=True)])
number = dvc.result()

def run(self):
self.number = self.inp[0].number + self.inp[1].number
Expand All @@ -57,8 +57,8 @@ class SummationTuple:
Additionally testing for tuple conversion here!
"""

inp = DVC.deps((AddOne(load=True), SubtractOne(load=True)))
number = DVC.result()
inp = dvc.deps((AddOne(load=True), SubtractOne(load=True)))
number = dvc.result()

def run(self):
self.number = self.inp[0].number + self.inp[1].number
Expand Down
6 changes: 3 additions & 3 deletions CI/integration_tests/test_multiple_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os
from tempfile import TemporaryDirectory

from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
import numpy as np

cwd = os.getcwd()
Expand All @@ -24,8 +24,8 @@ class ComputeA:
"""Node stage A"""

def __init__(self):
self.inp = DVC.params()
self.out = DVC.result()
self.inp = dvc.params()
self.out = dvc.result()

def __call__(self, inp):
self.inp = inp
Expand Down
6 changes: 3 additions & 3 deletions CI/integration_tests/test_numpy_params_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
from tempfile import TemporaryDirectory

from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
import numpy as np

temp_dir = TemporaryDirectory()
Expand All @@ -28,8 +28,8 @@ class ComputeA:
"""Node stage A"""

def __init__(self):
self.inp = DVC.params()
self.out = DVC.result()
self.inp = dvc.params()
self.out = dvc.result()

def __call__(self, inp):
self.inp = inp
Expand Down
13 changes: 10 additions & 3 deletions CI/integration_tests/test_params_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
Description:
"""
from zntrack import Node, DVC
from zntrack import Node, dvc
import os
import pytest


@Node()
class CheckType:
params = DVC.params()
params = dvc.params()

def __call__(self, params):
self.params = params
Expand Down Expand Up @@ -45,7 +45,14 @@ def fix_int() -> int:
return 42


@pytest.mark.parametrize('arg', ['fix_list', 'fix_int', 'fix_dict'], indirect=True)
@pytest.fixture
def fix_empty_list() -> list:
return []


@pytest.mark.parametrize(
"arg", ["fix_list", "fix_int", "fix_dict", "fix_empty_list"], indirect=True
)
def test_params(arg, tmp_path):
os.chdir(tmp_path)

Expand Down
8 changes: 4 additions & 4 deletions CI/integration_tests/test_passed_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
from tempfile import TemporaryDirectory

from zntrack import Node, DVC, ZnTrackProject
from zntrack import Node, dvc, ZnTrackProject
import numpy as np

temp_dir = TemporaryDirectory()
Expand All @@ -29,12 +29,12 @@
@Node()
class Model:
def __init__(self):
self.model_params = DVC.params()
self.model_class = DVC.params()
self.model_params = dvc.params()
self.model_class = dvc.params()

self.model_dict = {Model1.__name__: Model1, Model2.__name__: Model2}

self.result = DVC.result()
self.result = dvc.result()

def __call__(self, model):
self.model_params = model.params
Expand Down
6 changes: 3 additions & 3 deletions CI/integration_tests/test_stage_stage_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
Description:
"""
from zntrack import Node, DVC
from zntrack import Node, dvc
import shutil
import os


@Node()
class Stage1:
args = DVC.params()
args = dvc.params()

def __call__(self, args):
self.args = args
Expand All @@ -26,7 +26,7 @@ def run(self):

@Node()
class Stage2:
stage_1: Stage1 = DVC.deps(Stage1(load=True))
stage_1: Stage1 = dvc.deps(Stage1(load=True))

def __call__(self, *args, **kwargs):
pass
Expand Down
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
|build| |docs| |license| |code style|

ZnTrack
-------
.. image:: https://raw.githubusercontent.com/zincware/ZnTrack/main/docs/source/img/zntrack.png

Object-Relational Mapping for DVC
---------------------------------

The ZnTrack :code:`zɪŋk træk` package provides a Python ORM for DVC.

For more information on DVC visit their `homepage <https://dvc.org/doc>`_.
Expand Down
Loading

0 comments on commit 62e55b2

Please sign in to comment.