Skip to content

Commit c65370d

Browse files
authored
feat(serverless_jobs): add local storage limit (#437)
1 parent 9a509bc commit c65370d

File tree

6 files changed

+72
-8
lines changed

6 files changed

+72
-8
lines changed

scaleway-async/scaleway_async/jobs/v1alpha1/api.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async def create_job_definition(
5555
description: str,
5656
region: Optional[Region] = None,
5757
name: Optional[str] = None,
58+
local_storage_capacity: Optional[int] = None,
5859
project_id: Optional[str] = None,
5960
environment_variables: Optional[Dict[str, str]] = None,
6061
job_timeout: Optional[str] = None,
@@ -65,7 +66,8 @@ async def create_job_definition(
6566
:param region: Region to target. If none is passed will use default region from the config.
6667
:param name: Name of the job definition.
6768
:param cpu_limit: CPU limit of the job.
68-
:param memory_limit: Memory limit of the job.
69+
:param memory_limit: Memory limit of the job (in MiB).
70+
:param local_storage_capacity: Local storage capacity of the job (in MiB).
6971
:param image_uri: Image to use for the job.
7072
:param command: Startup command.
7173
:param project_id: UUID of the Scaleway Project containing the job.
@@ -103,6 +105,7 @@ async def create_job_definition(
103105
description=description,
104106
region=region,
105107
name=name or random_name(prefix="job"),
108+
local_storage_capacity=local_storage_capacity,
106109
project_id=project_id,
107110
environment_variables=environment_variables,
108111
job_timeout=job_timeout,
@@ -235,6 +238,7 @@ async def update_job_definition(
235238
name: Optional[str] = None,
236239
cpu_limit: Optional[int] = None,
237240
memory_limit: Optional[int] = None,
241+
local_storage_capacity: Optional[int] = None,
238242
image_uri: Optional[str] = None,
239243
command: Optional[str] = None,
240244
environment_variables: Optional[Dict[str, str]] = None,
@@ -248,7 +252,8 @@ async def update_job_definition(
248252
:param job_definition_id: UUID of the job definition to update.
249253
:param name: Name of the job definition.
250254
:param cpu_limit: CPU limit of the job.
251-
:param memory_limit: Memory limit of the job.
255+
:param memory_limit: Memory limit of the job (in MiB).
256+
:param local_storage_capacity: Local storage capacity of the job (in MiB).
252257
:param image_uri: Image to use for the job.
253258
:param command: Startup command.
254259
:param environment_variables: Environment variables of the job.
@@ -280,6 +285,7 @@ async def update_job_definition(
280285
name=name,
281286
cpu_limit=cpu_limit,
282287
memory_limit=memory_limit,
288+
local_storage_capacity=local_storage_capacity,
283289
image_uri=image_uri,
284290
command=command,
285291
environment_variables=environment_variables,

scaleway-async/scaleway_async/jobs/v1alpha1/marshalling.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def unmarshal_JobDefinition(data: Any) -> JobDefinition:
7676
field = data.get("job_timeout", None)
7777
args["job_timeout"] = field
7878

79+
field = data.get("local_storage_capacity", None)
80+
args["local_storage_capacity"] = field
81+
7982
field = data.get("memory_limit", None)
8083
args["memory_limit"] = field
8184

@@ -126,6 +129,9 @@ def unmarshal_JobRun(data: Any) -> JobRun:
126129
field = data.get("job_definition_id", None)
127130
args["job_definition_id"] = field
128131

132+
field = data.get("local_storage_capacity", None)
133+
args["local_storage_capacity"] = field
134+
129135
field = data.get("memory_limit", None)
130136
args["memory_limit"] = field
131137

@@ -274,6 +280,9 @@ def marshal_CreateJobDefinitionRequest(
274280
if request.job_timeout is not None:
275281
output["job_timeout"] = request.job_timeout
276282

283+
if request.local_storage_capacity is not None:
284+
output["local_storage_capacity"] = request.local_storage_capacity
285+
277286
if request.memory_limit is not None:
278287
output["memory_limit"] = request.memory_limit
279288

@@ -346,6 +355,9 @@ def marshal_UpdateJobDefinitionRequest(
346355
if request.job_timeout is not None:
347356
output["job_timeout"] = request.job_timeout
348357

358+
if request.local_storage_capacity is not None:
359+
output["local_storage_capacity"] = request.local_storage_capacity
360+
349361
if request.memory_limit is not None:
350362
output["memory_limit"] = request.memory_limit
351363

scaleway-async/scaleway_async/jobs/v1alpha1/types.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class JobDefinition:
9191

9292
cron_schedule: Optional[CronSchedule]
9393

94+
local_storage_capacity: int
95+
9496
region: Region
9597

9698

@@ -122,6 +124,8 @@ class JobRun:
122124

123125
environment_variables: Dict[str, str]
124126

127+
local_storage_capacity: int
128+
125129
region: Region
126130

127131

@@ -176,7 +180,12 @@ class CreateJobDefinitionRequest:
176180

177181
memory_limit: int
178182
"""
179-
Memory limit of the job.
183+
Memory limit of the job (in MiB).
184+
"""
185+
186+
local_storage_capacity: Optional[int]
187+
"""
188+
Local storage capacity of the job (in MiB).
180189
"""
181190

182191
image_uri: str
@@ -265,7 +274,12 @@ class UpdateJobDefinitionRequest:
265274

266275
memory_limit: Optional[int]
267276
"""
268-
Memory limit of the job.
277+
Memory limit of the job (in MiB).
278+
"""
279+
280+
local_storage_capacity: Optional[int]
281+
"""
282+
Local storage capacity of the job (in MiB).
269283
"""
270284

271285
image_uri: Optional[str]

scaleway/scaleway/jobs/v1alpha1/api.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def create_job_definition(
5555
description: str,
5656
region: Optional[Region] = None,
5757
name: Optional[str] = None,
58+
local_storage_capacity: Optional[int] = None,
5859
project_id: Optional[str] = None,
5960
environment_variables: Optional[Dict[str, str]] = None,
6061
job_timeout: Optional[str] = None,
@@ -65,7 +66,8 @@ def create_job_definition(
6566
:param region: Region to target. If none is passed will use default region from the config.
6667
:param name: Name of the job definition.
6768
:param cpu_limit: CPU limit of the job.
68-
:param memory_limit: Memory limit of the job.
69+
:param memory_limit: Memory limit of the job (in MiB).
70+
:param local_storage_capacity: Local storage capacity of the job (in MiB).
6971
:param image_uri: Image to use for the job.
7072
:param command: Startup command.
7173
:param project_id: UUID of the Scaleway Project containing the job.
@@ -103,6 +105,7 @@ def create_job_definition(
103105
description=description,
104106
region=region,
105107
name=name or random_name(prefix="job"),
108+
local_storage_capacity=local_storage_capacity,
106109
project_id=project_id,
107110
environment_variables=environment_variables,
108111
job_timeout=job_timeout,
@@ -235,6 +238,7 @@ def update_job_definition(
235238
name: Optional[str] = None,
236239
cpu_limit: Optional[int] = None,
237240
memory_limit: Optional[int] = None,
241+
local_storage_capacity: Optional[int] = None,
238242
image_uri: Optional[str] = None,
239243
command: Optional[str] = None,
240244
environment_variables: Optional[Dict[str, str]] = None,
@@ -248,7 +252,8 @@ def update_job_definition(
248252
:param job_definition_id: UUID of the job definition to update.
249253
:param name: Name of the job definition.
250254
:param cpu_limit: CPU limit of the job.
251-
:param memory_limit: Memory limit of the job.
255+
:param memory_limit: Memory limit of the job (in MiB).
256+
:param local_storage_capacity: Local storage capacity of the job (in MiB).
252257
:param image_uri: Image to use for the job.
253258
:param command: Startup command.
254259
:param environment_variables: Environment variables of the job.
@@ -280,6 +285,7 @@ def update_job_definition(
280285
name=name,
281286
cpu_limit=cpu_limit,
282287
memory_limit=memory_limit,
288+
local_storage_capacity=local_storage_capacity,
283289
image_uri=image_uri,
284290
command=command,
285291
environment_variables=environment_variables,

scaleway/scaleway/jobs/v1alpha1/marshalling.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def unmarshal_JobDefinition(data: Any) -> JobDefinition:
7676
field = data.get("job_timeout", None)
7777
args["job_timeout"] = field
7878

79+
field = data.get("local_storage_capacity", None)
80+
args["local_storage_capacity"] = field
81+
7982
field = data.get("memory_limit", None)
8083
args["memory_limit"] = field
8184

@@ -126,6 +129,9 @@ def unmarshal_JobRun(data: Any) -> JobRun:
126129
field = data.get("job_definition_id", None)
127130
args["job_definition_id"] = field
128131

132+
field = data.get("local_storage_capacity", None)
133+
args["local_storage_capacity"] = field
134+
129135
field = data.get("memory_limit", None)
130136
args["memory_limit"] = field
131137

@@ -274,6 +280,9 @@ def marshal_CreateJobDefinitionRequest(
274280
if request.job_timeout is not None:
275281
output["job_timeout"] = request.job_timeout
276282

283+
if request.local_storage_capacity is not None:
284+
output["local_storage_capacity"] = request.local_storage_capacity
285+
277286
if request.memory_limit is not None:
278287
output["memory_limit"] = request.memory_limit
279288

@@ -346,6 +355,9 @@ def marshal_UpdateJobDefinitionRequest(
346355
if request.job_timeout is not None:
347356
output["job_timeout"] = request.job_timeout
348357

358+
if request.local_storage_capacity is not None:
359+
output["local_storage_capacity"] = request.local_storage_capacity
360+
349361
if request.memory_limit is not None:
350362
output["memory_limit"] = request.memory_limit
351363

scaleway/scaleway/jobs/v1alpha1/types.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class JobDefinition:
9191

9292
cron_schedule: Optional[CronSchedule]
9393

94+
local_storage_capacity: int
95+
9496
region: Region
9597

9698

@@ -122,6 +124,8 @@ class JobRun:
122124

123125
environment_variables: Dict[str, str]
124126

127+
local_storage_capacity: int
128+
125129
region: Region
126130

127131

@@ -176,7 +180,12 @@ class CreateJobDefinitionRequest:
176180

177181
memory_limit: int
178182
"""
179-
Memory limit of the job.
183+
Memory limit of the job (in MiB).
184+
"""
185+
186+
local_storage_capacity: Optional[int]
187+
"""
188+
Local storage capacity of the job (in MiB).
180189
"""
181190

182191
image_uri: str
@@ -265,7 +274,12 @@ class UpdateJobDefinitionRequest:
265274

266275
memory_limit: Optional[int]
267276
"""
268-
Memory limit of the job.
277+
Memory limit of the job (in MiB).
278+
"""
279+
280+
local_storage_capacity: Optional[int]
281+
"""
282+
Local storage capacity of the job (in MiB).
269283
"""
270284

271285
image_uri: Optional[str]

0 commit comments

Comments
 (0)