Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

M 6769474660 save pipelines #192

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Changes from all 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
6 changes: 4 additions & 2 deletions aixplain/modules/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,13 @@ def run_async(
response["error"] = resp
return response

def update(self, pipeline: Union[Text, Dict], save_as_asset: bool = False):
def update(self, pipeline: Union[Text, Dict], save_as_asset: bool = False, api_key: Optional[Text] = None):
"""Update Pipeline

Args:
pipeline (Union[Text, Dict]): Pipeline as a Python dictionary or in a JSON file
save_as_asset (bool, optional): Save as asset (True) or draft (False). Defaults to False.
api_key (Optional[Text], optional): Team API Key to create the Pipeline. Defaults to None.

Raises:
Exception: Make sure the pipeline to be save is in a JSON file.
Expand All @@ -337,7 +338,8 @@ def update(self, pipeline: Union[Text, Dict], save_as_asset: bool = False):
status = "onboarded"
payload = {"name": self.name, "status": status, "architecture": pipeline}
url = urljoin(config.BACKEND_URL, f"sdk/pipelines/{self.id}")
headers = {"Authorization": f"Token {config.TEAM_API_KEY}", "Content-Type": "application/json"}
api_key = api_key if api_key is not None else config.TEAM_API_KEY
headers = {"Authorization": f"Token {api_key}", "Content-Type": "application/json"}
logging.info(f"Start service for PUT Update Pipeline - {url} - {headers} - {json.dumps(payload)}")
r = _request_with_retry("put", url, headers=headers, json=payload)
response = r.json()
Expand Down