diff --git a/aixplain/factories/pipeline_factory.py b/aixplain/factories/pipeline_factory.py index 404a5556..ce552712 100644 --- a/aixplain/factories/pipeline_factory.py +++ b/aixplain/factories/pipeline_factory.py @@ -45,6 +45,11 @@ class PipelineFactory: aixplain_key = config.AIXPLAIN_API_KEY backend_url = config.BACKEND_URL + @classmethod + def __get_typed_nodes(cls, response: Dict, type: str) -> List[Dict]: + # read "nodes" field from response and return the nodes that are marked by "type": type + return [node for node in response["nodes"] if node["type"].lower() == type.lower()] + @classmethod def __from_response(cls, response: Dict) -> Pipeline: """Converts response Json to 'Pipeline' object @@ -57,7 +62,9 @@ def __from_response(cls, response: Dict) -> Pipeline: """ if "api_key" not in response: response["api_key"] = config.TEAM_API_KEY - return Pipeline(response["id"], response["name"], response["api_key"]) + input = cls.__get_typed_nodes(response, "input") + output = cls.__get_typed_nodes(response, "output") + return Pipeline(response["id"], response["name"], response["api_key"], input=input, output=output) @classmethod def get(cls, pipeline_id: Text, api_key: Optional[Text] = None) -> Pipeline: @@ -73,7 +80,9 @@ def get(cls, pipeline_id: Text, api_key: Optional[Text] = None) -> Pipeline: resp = None try: url = urljoin(cls.backend_url, f"sdk/pipelines/{pipeline_id}") - if cls.aixplain_key != "": + if api_key is not None: + headers = {"Authorization": f"Token {api_key}", "Content-Type": "application/json"} + elif cls.aixplain_key != "": headers = {"x-aixplain-key": f"{cls.aixplain_key}", "Content-Type": "application/json"} else: headers = {"Authorization": f"Token {config.TEAM_API_KEY}", "Content-Type": "application/json"} diff --git a/pyproject.toml b/pyproject.toml index 112c8f9a..73980717 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ namespaces = true [project] name = "aiXplain" -version = "0.2.12" +version = "0.2.13rc2" description = "aiXplain SDK adds AI functions to software." readme = "README.md" requires-python = ">=3.5, <4"