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

upgrade pyre version in fbcode/torchx - batch 1 #818

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
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
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
Loading