Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4470da

Browse files
author
Nicanor Gutiérrez Requejo
committed
Merge branch 'add-support-for-custom-scheduler' into 'master'
Add support for custom scheduler See merge request wuxi-nextcode/research-platform/backend-services/platform/python-sdk!52
2 parents 5ed14cd + 1fa8720 commit e4470da

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

nextcode/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.14.1
1+
1.15.0

nextcode/services/workflow/pytest_plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ def pytest_addoption(parser):
9595
help="Specifies the credentials to forward to workflow-service",
9696
default=[],
9797
)
98+
group.addoption(
99+
"--scheduler_name",
100+
action="store",
101+
dest="scheduler_name",
102+
help="Specifies the scheduler to use in the pipeline run",
103+
default=None,
104+
)
98105
parser.addini(
99106
"base_upload_bucket",
100107
"The S3 location the result_dir parameter of the pipeline will be set to",
@@ -166,6 +173,7 @@ def run_workflow(request):
166173
run_id = request.config.option.run_id
167174
storage_type = request.config.option.storage_type
168175
credentials_args = request.config.option.credentials
176+
scheduler_name = request.config.option.scheduler_name
169177
# Use the profile specified by the TestCase if it exists. Use the default profile if none is provided.
170178
profile = getattr(request.cls, "profile", request.config.option.profile)
171179
revision = None
@@ -215,6 +223,7 @@ def run_workflow(request):
215223
profile=profile,
216224
storage_type=storage_type,
217225
credentials=credentials,
226+
scheduler_name=scheduler_name,
218227
)
219228

220229
last_status = ""

nextcode/services/workflow/service.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def post_job(
187187
keep_resources: Optional[bool] = None,
188188
mount_jobs: Optional[List[int]] = None,
189189
credentials: Optional[Dict] = None,
190+
scheduler_name: Optional[str] = None,
190191
):
191192
"""
192193
Run a workflow job
@@ -224,6 +225,8 @@ def post_job(
224225
'aws_secret_access_key': 'k6q5...'
225226
}
226227
}
228+
:param scheduler_name: Optional string specifying the scheduler to use. If not specified, the default scheduler
229+
will be used
227230
"""
228231
if not project_name:
229232
project_name = os.environ.get("GOR_API_PROJECT")
@@ -234,7 +237,7 @@ def post_job(
234237
log.debug(
235238
"post_job called with pipeline_name=%s, project_name=%s, params=%s, script=%s, revision=%s, "
236239
"build_source=%s, build_context=%s, profile=%s, description=%s, executor_memory_mb=%s, context=%s, "
237-
"storage_type=%s, dedicated_storage_size=%s, mount_jobs=%s",
240+
"storage_type=%s, dedicated_storage_size=%s, mount_jobs=%s scheduler_name=%s",
238241
pipeline_name,
239242
project_name,
240243
params,
@@ -249,6 +252,7 @@ def post_job(
249252
storage_type,
250253
dedicated_storage_size,
251254
mount_jobs,
255+
scheduler_name,
252256
)
253257
data: Dict = {
254258
"pipeline_name": pipeline_name,
@@ -278,6 +282,8 @@ def post_job(
278282
data["keep_resources"] = keep_resources
279283
if mount_jobs:
280284
data["mount_jobs"] = mount_jobs
285+
if scheduler_name:
286+
data["scheduler_name"] = scheduler_name
281287

282288
endpoint = self.session.url_from_endpoint("jobs")
283289

tests/test_workflow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def test_post_job(self):
247247
build_context = None
248248
profile = "test"
249249
storage_type = "dedicated"
250+
scheduler_name = "custom-scheduler"
250251

251252
job = self.svc.post_job(
252253
pipeline_name,
@@ -258,6 +259,7 @@ def test_post_job(self):
258259
build_context,
259260
profile,
260261
storage_type,
262+
scheduler_name,
261263
)
262264
self.assertEqual(666, job.job_id)
263265

@@ -280,6 +282,7 @@ def test_post_job_with_creds(self):
280282
"aws_secret_access_key": "Aj39sadfljhdslafjasls",
281283
}
282284
}
285+
scheduler_name = "custom-scheduler"
283286

284287
job = self.svc.post_job(
285288
pipeline_name,
@@ -292,6 +295,7 @@ def test_post_job_with_creds(self):
292295
profile,
293296
storage_type,
294297
credentials,
298+
scheduler_name,
295299
)
296300
self.assertEqual(666, job.job_id)
297301

0 commit comments

Comments
 (0)