Skip to content

Commit

Permalink
chore(Pipeline): Refactor main function
Browse files Browse the repository at this point in the history
  • Loading branch information
qgerome committed May 27, 2024
1 parent 1eb50ad commit 524a29d
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions images/base/files/scripts/bootstrap_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,16 @@ def version_info():
"--config", default=None, help="Pipeline configuration base64 encoded"
)
args = parser.parse_args()
pipeline_config = (
json.loads(base64.b64decode(args.config).decode("utf-8")) if args.config else {}
)

if args.command == "cloudrun":
configure_cloud_run()
# cloud run -> need to download the code from cloud (except for notebooks as pipeline)
if "HEXA_TOKEN" not in os.environ or "HEXA_SERVER_URL" not in os.environ:
print("Need token and url to download the code", file=sys.stderr)
sys.exit(1)

if args.command in ("cloudrun", "run"):
args_config = (
json.loads(base64.b64decode(args.config).decode("utf-8"))
if args.config
else {}
)
if os.getenv("HEXA_PIPELINE_TYPE", "zipFile") == "zipFile":
run_id = os.environ["HEXA_RUN_ID"]
access_token = os.environ["HEXA_TOKEN"]
Expand All @@ -130,14 +126,11 @@ def version_info():

print("Pipeline downloaded.")

run_pipeline(args_config)
run_pipeline(pipeline_config)

# FIXME: We should find a better place to handle this (if it is even needed).
if args.command == "cloudrun" and os.path.exists(
"/home/jovyan/.hexa_scripts/fuse_umount.py"
):
# clean up fuse & umount at the end
import fuse_umount # noqa: F401, E402
else:
parser.print_help()
sys.exit(1)
# FIXME: We should find a better place to handle this (if it is even needed).
if args.command == "cloudrun" and os.path.exists(
"/home/jovyan/.hexa_scripts/fuse_umount.py"
):
# clean up fuse & umount at the end
import fuse_umount # noqa: F401, E402

0 comments on commit 524a29d

Please sign in to comment.