-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
55 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
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 |
---|---|---|
@@ -1,33 +1,45 @@ | ||
# pylint: disable=no-member,wrong-import-position,no-name-in-module | ||
from typing import Union | ||
import instill.protogen.vdp.pipeline.v1beta.pipeline_pb2 as pipeline_interface | ||
|
||
from instill.protogen.vdp.pipeline.v1beta.pipeline_pb2 import Component as Comp | ||
from instill.protogen.vdp.pipeline.v1beta.pipeline_pb2 import ( | ||
ConnectorComponent, | ||
IteratorComponent, | ||
OperatorComponent, | ||
) | ||
from instill.resources.errors import ComponentTypeExection | ||
|
||
|
||
class Component: | ||
def __init__( | ||
self, | ||
name: str, | ||
component_type: str, | ||
component: Union[ | ||
pipeline_interface.ConnectorComponent, | ||
pipeline_interface.OperatorComponent, | ||
pipeline_interface.IteratorComponent, | ||
ConnectorComponent, | ||
OperatorComponent, | ||
IteratorComponent, | ||
], | ||
): | ||
c = pipeline_interface.Component() | ||
c.id = name | ||
|
||
if component_type == "connector": | ||
c.connector_component = component | ||
elif component_type == "operator": | ||
c.operator_component = component | ||
elif component_type == "iterator": | ||
c.iterator_component = component | ||
if isinstance(component, ConnectorComponent): | ||
c = Comp( | ||
id=name, | ||
connector_component=component, | ||
) | ||
elif isinstance(component, OperatorComponent): | ||
c = Comp( | ||
id=name, | ||
operator_component=component, | ||
) | ||
elif isinstance(component, IteratorComponent): | ||
c = Comp( | ||
id=name, | ||
iterator_component=component, | ||
) | ||
else: | ||
raise ComponentTypeExection | ||
|
||
self.c = c | ||
|
||
def get_component(self) -> pipeline_interface.Component: | ||
def get_component(self) -> Comp: | ||
return self.c |
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
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
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