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

have minimal tests up-to-date and working #20

Merged
merged 4 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 3 additions & 1 deletion pipeline/objects/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def execute_func(*args, **kwargs):
)
)

node_output = Variable(type_class=function.__annotations__["return"])
node_output = Variable(
type_class=function.__annotations__["return"], is_output=True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is correct, the is_output field is for when the variable is an output for the whole pipeline not a GraphNode. What's the motivation behind this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the errors the test caught was _output not being found within the variables set and this was raising an error, I thought perhaps when setting the functions we wanted to define as output their output

But from your comment I gather is_output is just for the whole pipeline not fro each node. I already have a change to fix the error while respecting this convention, just confirm if I understood correctly pls!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay gotcha, I thought I fixed this before actually my bad!
You can register it as an output node when builder.output(...) is called, this should be working it's weird that it's not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I'll review that bit to make it happen

)
# Pipeline.add_variable(node_output)
Pipeline.add_function(function.__pipeline_function__)
new_node = GraphNode(
Expand Down
4 changes: 2 additions & 2 deletions pipeline/objects/graph_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class GraphNode:
local_id: str
function: Function
inputs = [] #: List[Variable]
outputs = [] #: List[Variable]
inputs: List[Variable] = []
outputs: List[Variable] = []

def __init__(self, function, inputs, outputs, *, local_id=None):
self.function = function
Expand Down
8 changes: 8 additions & 0 deletions pipeline/objects/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def __exit__(self, type, value, traceback):

def output(self, *outputs: Variable) -> None:
for _output in outputs:
if _output not in Pipeline._current_pipeline.variables:
# o = Variable(_output, is_output=True)
Pipeline.add_variable(_output)
variable_index = Pipeline._current_pipeline.variables.index(_output)
if variable_index != -1:
Pipeline._current_pipeline.variables[variable_index].is_output = True
Expand Down Expand Up @@ -64,6 +67,11 @@ def add_variable(variable: Variable) -> None:
else:
raise Exception("Cant add a variable when not defining a pipeline!")

@staticmethod
def add_variables(*variables: Variable) -> None:
for v in variables:
Pipeline.add_variable(v)

@staticmethod
def add_function(function: Function) -> None:
if Pipeline._pipeline_context_active:
Expand Down
6 changes: 0 additions & 6 deletions pipeline/objects/variable.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from typing import Any

# from pipeline.objects.pipeline import Pipeline
from pipeline.schemas.pipeline import PipelineVariableGet
from pipeline.util import generate_id, hex_to_python_object

# from pipeline.objects import Pipeline


class Variable:

Expand Down Expand Up @@ -37,9 +34,6 @@ def __init__(

self.local_id = generate_id(10) if not local_id else local_id

# if Pipeline._pipeline_context_active:
# Pipeline.add_variable(self)

@classmethod
def from_schema(cls, schema: PipelineVariableGet):
return cls(
Expand Down
24 changes: 22 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pipeline-ai"
version = "0.0.12"
version = "0.0.19"
description = "Yay ml pipelines"
authors = ["Paul Hetherington <paul@getneuro.ai>"]
packages = [
Expand All @@ -23,6 +23,7 @@ setuptools = "^59.2.0"
humps = "^0.2.2"
pyhumps = "^3.0.2"
requests-toolbelt = "^0.9.1"
tqdm = "^4.62.3"

[tool.poetry.dev-dependencies]
setuptools = "^59.2.0"
Expand Down
58 changes: 0 additions & 58 deletions tests/test_function_schemas.py

This file was deleted.

2 changes: 2 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def load(self, path: str) -> None:

with Pipeline("test") as my_pipeline:
in_1 = Variable(str, is_input=True)
my_pipeline.add_variable(in_1)

my_model = CustomModel()
str_1 = my_model.predict(in_1)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_pipeline_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_with_decorator_name():
# Test exit
def test_with_exit():
with Pipeline("test"):
Variable(is_input=True, is_output=True)
Variable(str, is_input=True, is_output=True)
assert Pipeline.get_pipeline("test").name == "test"


Expand All @@ -34,13 +34,13 @@ def square(f_1: float) -> float:
in_1 = Variable(float, is_input=True)
in_2 = Variable(float, is_input=True)

my_pipeline.add_variables(in_1, in_2)

add_1 = add(in_1, in_2)
sq_1 = square(add_1)

my_pipeline.output(sq_1, add_1)

graph = Pipeline.get_pipeline("test")

output = graph.run(2.0, 3.0)
output = Pipeline.run_local("test", 2.0, 3.0)
assert output == [25.0, 5.0]
assert Pipeline._current_pipeline is None
108 changes: 0 additions & 108 deletions tests/test_pipeline_schemas.py

This file was deleted.