Skip to content

Commit

Permalink
Merge pull request #107 from zincware/development
Browse files Browse the repository at this point in the history
ZnTrack [0.1.5]
  • Loading branch information
PythonFZ authored Nov 5, 2021
2 parents 41d1b19 + 27b122a commit d177ec6
Show file tree
Hide file tree
Showing 17 changed files with 30,915 additions and 56 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/black.yaml
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
58 changes: 58 additions & 0 deletions CI/integration_tests/dependencies/test_Node_metric.py
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
)
2 changes: 1 addition & 1 deletion CI/integration_tests/test_graph_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_stage_addition():

project.run()
project.load()
finished_stage = ComputeAB(id_=0)
finished_stage = ComputeAB(load=True)
assert finished_stage.out == 31


Expand Down
29 changes: 29 additions & 0 deletions CI/integration_tests/test_pre_call.py
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()
Loading

0 comments on commit d177ec6

Please sign in to comment.