Skip to content

Commit 362bb1c

Browse files
committed
Added checker for shape details for job
1 parent a7c7556 commit 362bb1c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ads/jobs/builders/infrastructure/dsc_job.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,12 @@ def _update_job_infra(self, dsc_job: DSCJob) -> DataScienceJob:
14501450
if value:
14511451
dsc_job.job_infrastructure_configuration_details[camel_attr] = value
14521452

1453+
if (
1454+
not dsc_job.job_infrastructure_configuration_details.get("shapeName", "").endswith("Flex")
1455+
and dsc_job.job_infrastructure_configuration_details.get("jobShapeConfigDetails")
1456+
):
1457+
raise ValueError("Shape config is not required for non flex shape from user end.")
1458+
14531459
if dsc_job.job_infrastructure_configuration_details.get("subnetId"):
14541460
dsc_job.job_infrastructure_configuration_details[
14551461
"jobInfrastructureType"

tests/unitary/default_setup/jobs/test_jobs_base.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,26 @@ def test_create_job_with_invalid_notebook_env(self):
473473
job.create()
474474
del os.environ["NB_SESSION_OCID"]
475475

476+
def test_job_with_non_flex_shape_and_shape_details(self):
477+
job = (
478+
Job(name="test")
479+
.with_infrastructure(
480+
infrastructure.DataScienceJob()
481+
.with_compartment_id("ocid1.compartment.oc1..<unique_ocid>")
482+
.with_project_id("ocid1.datascienceproject.oc1.iad.<unique_ocid>")
483+
.with_shape_name("VM.Standard2.1")
484+
.with_shape_config_details(memory_in_gbs=16, ocpus=1)
485+
.with_block_storage_size(50)
486+
)
487+
.with_runtime(ScriptRuntime().with_script(self.SCRIPT_URI))
488+
)
489+
490+
with pytest.raises(
491+
ValueError,
492+
match="Shape config is not required for non flex shape from user end."
493+
):
494+
job.create()
495+
476496

477497
class ScriptRuntimeArtifactTest(unittest.TestCase):
478498
DIR_SOURCE_PATH = os.path.join(os.path.dirname(__file__), "test_files/job_archive")

0 commit comments

Comments
 (0)