-
Notifications
You must be signed in to change notification settings - Fork 108
Pipeline viz #122
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
Merged
Merged
Pipeline viz #122
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
67d430c
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia e965499
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia ed0baa7
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia ea232ff
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 43c7b3c
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python in…
stellasia 8367daa
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 3c3c00e
Merge remote-tracking branch 'origin/main'
stellasia 7182523
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 212a5a3
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 32364c6
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia f481025
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 56435bf
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 2b21340
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python
stellasia 74f7d0b
Save input configs in the Pipeline class while validating, and reuse …
stellasia 059a302
Split the parameter connection validation and the user input validati…
stellasia f8696b6
WIP: pipeline visualization
stellasia 195f249
Invalidate the pipeline param mapping if the graph structure changes
stellasia a9aee54
Hide unused outputs by default but add option to display them
stellasia 77b2eb0
Install graphviz during CI
stellasia e6c2c10
Install graphviz-dev in CI to fix installation error
stellasia 1202484
Update changelog and doc
stellasia 43d6556
Add a few tests for data validation
stellasia 604fa5f
Merge branch 'main' of https://github.com/neo4j/neo4j-genai-python in…
stellasia 93a11ec
Fix error message
stellasia 7c5b9f9
This is a change of behavior that will be implemented in a separate PR
stellasia 6155341
Merge with main
stellasia 0261788
Add UT for pipeline to pygraphviz format and pipeline draw method
stellasia ee1a2cd
Fix docstring
stellasia 7a88268
Merge with main
stellasia 4494799
Improve naming and docstrings
stellasia b9e3c66
Update CHANGELOG.md
stellasia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 @@ | ||
# Copyright (c) "Neo4j" | ||
# Neo4j Sweden AB [https://neo4j.com] | ||
# # | ||
# 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 | ||
# # | ||
# https://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. | ||
"""This example illustrates how to visualize a Pipeline""" | ||
|
||
from neo4j_genai.experimental.pipeline import Component, Pipeline | ||
from neo4j_genai.experimental.pipeline.component import DataModel | ||
from pydantic import validate_call | ||
|
||
|
||
class IntDataModel(DataModel): | ||
value: int | ||
message: str | ||
|
||
|
||
class Addition(Component): | ||
async def run(self, a: int, b: int) -> IntDataModel: | ||
return IntDataModel(value=a + b, message="addition complete") | ||
|
||
|
||
class Duplicate(Component): | ||
def __init__(self, factor: int = 2) -> None: | ||
self.factor = factor | ||
|
||
async def run(self, number: int) -> IntDataModel: | ||
return IntDataModel( | ||
value=number * self.factor, message=f"multiplication by {self.factor} done" | ||
) | ||
|
||
|
||
class Save(Component): | ||
@validate_call | ||
async def run(self, number: IntDataModel) -> IntDataModel: | ||
return IntDataModel(value=number.value, message="saved") | ||
|
||
|
||
if __name__ == "__main__": | ||
pipe = Pipeline() | ||
pipe.add_component(Duplicate(), "times_two") | ||
pipe.add_component(Duplicate(factor=10), "times_ten") | ||
pipe.add_component(Addition(), "addition") | ||
pipe.add_component(Save(), "save") | ||
pipe.connect("times_two", "addition", {"a": "times_two.value"}) | ||
pipe.connect("times_ten", "addition", {"b": "times_ten.value"}) | ||
pipe.connect("addition", "save", {"number": "addition"}) | ||
pipe.draw("graph.png") | ||
pipe.draw("graph_full.png", hide_unused_outputs=False) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.