Skip to content

Commit

Permalink
torchx/schedulers
Browse files Browse the repository at this point in the history
Differential Revision: D52948910

Pull Request resolved: #807
  • Loading branch information
zsol committed Jan 24, 2024
1 parent 89cf8e1 commit 19497eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions torchx/schedulers/gcp_batch_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@ def _app_to_job(self, app: AppDef) -> "batch_v1.Job":
if cpu <= 0:
cpu = 1
MILLI = 1000
# pyre-fixme[8]: Attribute has type `Field`; used as `int`.
res.cpu_milli = cpu * MILLI
memMB = resource.memMB
if memMB < 0:
raise ValueError(
f"memMB should to be set to a positive value, got {memMB}"
)
# pyre-fixme[8]: Attribute has type `Field`; used as `int`.
res.memory_mib = memMB

# TODO support named resources
Expand Down Expand Up @@ -358,11 +360,13 @@ def describe(self, app_id: str) -> Optional[DescribeAppResponse]:
return None

gpu = 0
# pyre-fixme[16]: `Field` has no attribute `instances`.
if len(job.allocation_policy.instances) != 0:
gpu_type = job.allocation_policy.instances[0].policy.machine_type
gpu = GPU_TYPE_TO_COUNT[gpu_type]

roles = {}
# pyre-fixme[16]: `RepeatedField` has no attribute `__iter__`.
for tg in job.task_groups:
env = tg.task_spec.environment.variables
role = env["TORCHX_ROLE_NAME"]
Expand All @@ -386,6 +390,7 @@ def describe(self, app_id: str) -> Optional[DescribeAppResponse]:
# TODO map role/replica status
desc = DescribeAppResponse(
app_id=app_id,
# pyre-fixme[16]: `Field` has no attribute `state`.
state=JOB_STATE[job.status.state.name],
roles=list(roles.values()),
)
Expand Down
2 changes: 2 additions & 0 deletions torchx/schedulers/test/gcp_batch_scheduler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def test_submit_dryrun(self) -> None:
env["TORCHX_ROLE_NAME"] = "trainer"
env["FOO"] = "bar"
res = batch_v1.ComputeResource()
# pyre-fixme[8]: Attribute has type `Field`; used as `int`.
res.cpu_milli = 2000
# pyre-fixme[8]: Attribute has type `Field`; used as `int`.
res.memory_mib = 3000
allocationPolicy = batch_v1.AllocationPolicy(
instances=[
Expand Down

0 comments on commit 19497eb

Please sign in to comment.