Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Parallelize manual_aq_tests/initialize.py #1180

Merged
merged 4 commits into from
Apr 6, 2023
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
63 changes: 53 additions & 10 deletions manual_qa_tests/initialize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
from multiprocessing import Process

import deploy_example
from aqueduct.constants.enums import NotificationLevel
Expand Down Expand Up @@ -47,6 +48,24 @@
TEMP_NOTEBOOK_PATH = "temp.py"
RUN_NOTEBOOK_SCRIPT = "examples/run_notebook.py"


def deploy_example_notebook(deploy_fn, dir_path, notebook_name, api_key, address) -> None:
print(f"Deploying example notebooks {notebook_name}...")
deploy_fn(
dir_path,
notebook_name,
TEMP_NOTEBOOK_PATH,
address,
api_key,
)


def deploy_flow(name, deploy_fn, api_key, address, data_integration) -> None:
print(f"Deploying {name}...")
client = aq.Client(api_key, address)
deploy_fn(client, data_integration)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--addr", default="localhost:8080")
Expand All @@ -60,6 +79,7 @@
parser.add_argument("--slack-channel", default="")
parser.add_argument("--notification-level", default="success")
parser.add_argument("--wait-to-complete", action="store_true")
parser.add_argument("--single-threaded", action="store_true")
args = parser.parse_args()

api_key = args.api_key if args.api_key else aq.get_apikey()
Expand All @@ -73,25 +93,48 @@
NotificationLevel(args.notification_level),
)

# This is only populated in the default multi-process case.
processes = []

if args.example_notebooks or args.example_notebooks_only or args.demo_container_notebooks_only:
notebooks = DEMO_NOTEBOOKS_PATHS
if not args.demo_container_notebooks_only:
notebooks += ADDITIONAL_EXAMPLE_NOTEBOOKS_PATHS

for example_path in notebooks:
print(f"Deploying example notebooks {example_path[1]}...")
deploy_example.deploy(
example_path[0],
example_path[1],
TEMP_NOTEBOOK_PATH,
args.addr,
api_key,
)
if args.single_threaded:
deploy_example_notebook(
deploy_example.deploy, example_path[0], example_path[1], api_key, args.addr
)
else:
p = Process(
target=deploy_example_notebook,
args=(
deploy_example.deploy,
example_path[0],
example_path[1],
api_key,
args.addr,
),
)
processes.append(p)
p.start()

if not args.example_notebooks_only and not args.demo_container_notebooks_only:
for pkg in WORKFLOW_PKGS:
print(f"Deploying {pkg.NAME}...")
pkg.deploy(client, args.data_integration)
if args.single_threaded:
deploy_flow(pkg.NAME, pkg.deploy, api_key, args.addr, args.data_integration)
else:
p = Process(
target=deploy_flow,
args=(pkg.NAME, pkg.deploy, api_key, args.addr, args.data_integration),
)
processes.append(p)
p.start()

if len(processes) > 0:
for p in processes:
p.join()

if args.wait_to_complete:
wait_for_all_flows_to_complete(client)