Skip to content

Commit

Permalink
v0.1.1 release.
Browse files Browse the repository at this point in the history
Merge branch 'develop' into main.
  • Loading branch information
karno committed Jan 22, 2021
2 parents 2d9cbc9 + d54c001 commit 504a187
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "kfp-deployer"
version = "0.1.0"
version = "0.1.1"
description = "Deploy the KFP ML Pipeline from CLI."
authors = ["Karno <[email protected]>"]
readme = "README.md"
Expand Down
42 changes: 30 additions & 12 deletions src/kfp_deployer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@

import argparse
from datetime import datetime
from typing import Optional
from pytz import timezone
import kfp
from typing import Iterable, NamedTuple, Optional

LIST_PAGE_SIZE = 1000
import kfp
from pytz import timezone

KNOWN_TIMEZONE_TABLE = {"JST": "Asia/Tokyo"}


class Pipeline(NamedTuple):
"""Describes a pipeline deployed on the KFP instance."""

id: str
name: str


def main() -> None:
"""Entrypoint."""
parser = _build_argparser()
Expand Down Expand Up @@ -68,17 +74,29 @@ def get_pipeline_id(client: kfp.Client, pipeline_name: str) -> Optional[str]:
Returns:
Optional[str]: If found, return Pipeline ID. If not, return None.
"""
pipelines_list = client.list_pipelines(page_size=LIST_PAGE_SIZE)
if pipelines_list.pipelines:
# check pipelines_list.pipelines is not null
for p in pipelines_list.pipelines:
if p.name == pipeline_name:
# found
return p.id
for p in _iterate_pipelines(client):
if p.name == pipeline_name:
return p.id
# not found
return None


def _iterate_pipelines(client: kfp.Client) -> Iterable[Pipeline]:
token: Optional[str] = None
while True:
pipelines_list = client.list_pipelines(page_token=token)
# handle the response
for p in pipelines_list.pipelines:
p_obj = Pipeline(p.id, p.name)
yield p_obj
# go on to the next page
token = pipelines_list.next_page_token
if token is None:
# when the reading page reached to the end,
# next_page_token will be None.
return


def deploy_new_pipeline(
client: kfp.Client, pipeline_name: str, pipeline_file_path: str
) -> str:
Expand Down Expand Up @@ -139,4 +157,4 @@ def create_version_str(


if __name__ == "__main__":
main()
main()

0 comments on commit 504a187

Please sign in to comment.