Skip to content

Commit

Permalink
remove accounting_group & sort args
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Aug 17, 2023
1 parent f74b2d1 commit 2b7bdc2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 55 deletions.
38 changes: 19 additions & 19 deletions clientmanager/clientmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,7 @@ def wait_for_file(waitee: Path, wait_time: int) -> Path:
help="where to save logs (if not given, logs are not saved)",
)

# condor args
sub_parser.add_argument(
"--n-workers",
required=True,
type=int,
help="number of worker to start",
)
# worker args
sub_parser.add_argument(
"--memory",
required=True,
Expand All @@ -159,21 +153,14 @@ def wait_for_file(waitee: Path, wait_time: int) -> Path:
type=int,
help="number of cores per worker",
)

# client args
sub_parser.add_argument(
"--image",
"--n-workers",
required=True,
help="a path or url to the workers' image",
)
sub_parser.add_argument(
"--client-startup-json",
help="The 'startup.json' file to startup each client",
type=lambda x: wait_for_file(
Path(x),
ENV.CLIENT_STARTER_WAIT_FOR_STARTUP_JSON,
),
type=int,
help="number of worker to start",
)

# client args
sub_parser.add_argument(
"--client-args",
required=False,
Expand All @@ -185,6 +172,19 @@ def wait_for_file(waitee: Path, wait_time: int) -> Path:
),
help="n 'key:value' pairs containing the python CL arguments to pass to skymap_scanner.client",
)
sub_parser.add_argument(
"--client-startup-json",
help="The 'startup.json' file to startup each client",
type=lambda x: wait_for_file(
Path(x),
ENV.CLIENT_STARTER_WAIT_FOR_STARTUP_JSON,
),
)
sub_parser.add_argument(
"--image",
required=True,
help="a path or url to the workers' image",
)

@staticmethod
def stopper(sub_parser: argparse.ArgumentParser) -> None:
Expand Down
23 changes: 12 additions & 11 deletions clientmanager/condor/act.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ def _act(args: argparse.Namespace, schedd_obj: htcondor.Schedd) -> None:
skydriver_rc = utils.connect_to_skydriver()
# start
submit_result_obj = starter.start(
schedd_obj,
args.n_workers,
args.logs_directory if args.logs_directory else None,
args.client_args,
args.memory,
args.n_cores,
args.accounting_group,
args.image,
# put client_startup_json in S3 bucket
utils.s3ify(args.client_startup_json),
args.dryrun,
schedd_obj=schedd_obj,
# starter CL args -- helper
dryrun=args.dryrun,
logs_directory=args.logs_directory if args.logs_directory else None,
# starter CL args -- worker
memory=args.memory,
n_cores=args.n_cores,
n_workers=args.n_workers,
# starter CL args -- client
client_args=args.client_args,
client_startup_json_s3=utils.s3ify(args.client_startup_json),
image=args.image,
)
# report to SkyDriver
utils.update_skydriver(
Expand Down
19 changes: 7 additions & 12 deletions clientmanager/condor/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import datetime as dt
import getpass
from pathlib import Path

import htcondor # type: ignore[import]
Expand Down Expand Up @@ -30,7 +29,6 @@ def make_condor_job_description( # pylint: disable=too-many-arguments
# condor args
memory: str,
n_cores: int,
accounting_group: str,
# skymap scanner args
image: str,
client_startup_json_s3: S3File,
Expand Down Expand Up @@ -91,24 +89,22 @@ def make_condor_job_description( # pylint: disable=too-many-arguments
# NOTE: this needs to be removed if we ARE transferring files
submit_dict["initialdir"] = "/tmp"

# accounting group
if accounting_group:
submit_dict["+AccountingGroup"] = f"{accounting_group}.{getpass.getuser()}"

return htcondor.Submit(submit_dict)


def start(
schedd_obj: htcondor.Schedd,
n_workers: int,
# starter CL args -- helper
dryrun: bool,
logs_directory: Path | None,
client_args: list[tuple[str, str]],
# starter CL args -- worker
memory: str,
n_cores: int,
accounting_group: str,
image: str,
n_workers: int,
# starter CL args -- client
client_args: list[tuple[str, str]],
client_startup_json_s3: S3File,
dryrun: bool,
image: str,
) -> htcondor.SubmitResult:
"""Main logic."""
if logs_directory:
Expand Down Expand Up @@ -138,7 +134,6 @@ def start(
# condor args
memory,
n_cores,
accounting_group,
# skymap scanner args
image,
client_startup_json_s3,
Expand Down
19 changes: 11 additions & 8 deletions clientmanager/k8s/act.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,22 @@ def _act(args: argparse.Namespace, k8s_client: kubernetes.client.ApiClient) -> N
# start
starter.start(
k8s_client=k8s_client,
job_config_stub=args.job_config_stub,
cluster_id=cluster_id,
# k8s CL args
cpu_arch=args.cpu_arch,
host=args.host,
job_config_stub=args.job_config_stub,
namespace=args.namespace,
cluster_id=cluster_id,
n_workers=args.n_workers,
# starter CL args -- helper
dryrun=args.dryrun,
# starter CL args -- worker
memory=args.memory,
n_cores=args.n_cores,
n_workers=args.n_workers,
# starter CL args -- client
client_args=args.client_args if args.client_args else [],
memory=args.memory,
container_image=args.image,
# put client_startup_json in S3 bucket
client_startup_json_s3=utils.s3ify(args.client_startup_json),
dryrun=args.dryrun,
cpu_arch=args.cpu_arch,
container_image=args.image,
)
# report to SkyDriver
utils.update_skydriver(
Expand Down
14 changes: 9 additions & 5 deletions clientmanager/k8s/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,22 @@ def add_override_env(new_env_dicts: list[dict[str, Any]]) -> None:

def start(
k8s_client: kubernetes.client.ApiClient,
cluster_id: str,
# k8s CL args
job_config_stub: Path,
host: str,
namespace: str,
cluster_id: str,
cpu_arch: str,
# starter CL args -- helper
dryrun: bool,
# starter CL args -- worker
memory: str,
n_workers: int,
n_cores: int,
# starter CL args -- client
client_args: list[tuple[str, str]],
memory: str,
container_image: str,
client_startup_json_s3: S3File,
dryrun: bool,
cpu_arch: str,
container_image: str,
) -> dict:
"""Main logic."""
if host == LOCAL_K8S_HOST and n_workers > ENV.WORKER_K8S_LOCAL_WORKERS_MAX:
Expand Down

0 comments on commit 2b7bdc2

Please sign in to comment.