From f648042e94da5bc424a1aa4e001fb132090b66a5 Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Mon, 27 Jun 2022 11:57:25 -0400 Subject: [PATCH 1/4] update sphinx config --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 7289c1164..dd7acca7b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -125,7 +125,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # For Adding Locale locale_dirs = ['locale/'] # path is example but recommended. From 2ae7f02c07c293437d202e19ac2cb4a35d041a33 Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Fri, 1 Jul 2022 10:36:39 -0400 Subject: [PATCH 2/4] fix custom max execution time test --- test/integration/test_job.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/test/integration/test_job.py b/test/integration/test_job.py index 761566c80..2779110a5 100644 --- a/test/integration/test_job.py +++ b/test/integration/test_job.py @@ -127,20 +127,10 @@ def test_run_program_failed_custom_max_execution_time(self, service): service, max_execution_time=max_execution_time ) inputs = {"iterations": 1, "sleep_per_iteration": 60} - job = self._run_program( - service, program_id=program_id, inputs=inputs, max_execution_time=1 - ) - job.wait_for_final_state() - job_result_raw = service._api_client.job_results(job.job_id) - self.assertEqual(JobStatus.ERROR, job.status()) - self.assertIn( - API_TO_JOB_ERROR_MESSAGE["CANCELLED - RAN TOO LONG"].format( - job.job_id, job_result_raw - ), - job.error_message(), - ) - with self.assertRaises(RuntimeJobFailureError): - job.result() + with self.assertRaises(IBMRuntimeError): + self._run_program( + service, program_id=program_id, inputs=inputs, max_execution_time=1 + ) @run_integration_test def test_run_program_failed_invalid_execution_time(self, service): From da13330e054a81b2d241a836adc44736e5ad0522 Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Fri, 1 Jul 2022 11:47:58 -0400 Subject: [PATCH 3/4] update test case --- test/integration/test_job.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/integration/test_job.py b/test/integration/test_job.py index 2779110a5..3322f533c 100644 --- a/test/integration/test_job.py +++ b/test/integration/test_job.py @@ -122,15 +122,20 @@ def test_run_program_failed_ran_too_long(self, service): def test_run_program_failed_custom_max_execution_time(self, service): """Test a program that failed with a custom max_execution_time.""" # check that program max execution time is overridden - max_execution_time = 300 + program_max_execution_time = 400 + job_max_execution_time = 350 program_id = self._upload_program( - service, max_execution_time=max_execution_time + service, max_execution_time=program_max_execution_time + ) + job = self._run_program( + service, program_id=program_id, max_execution_time=job_max_execution_time + ) + job.wait_for_final_state() + self.assertEqual( + job._api_client.job_get(job.job_id)["cost"], job_max_execution_time ) - inputs = {"iterations": 1, "sleep_per_iteration": 60} with self.assertRaises(IBMRuntimeError): - self._run_program( - service, program_id=program_id, inputs=inputs, max_execution_time=1 - ) + self._run_program(service, program_id=program_id, max_execution_time=1) @run_integration_test def test_run_program_failed_invalid_execution_time(self, service): From c24370c9285c7c42a2891a850e42dcbb30fd0fb6 Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Fri, 1 Jul 2022 12:31:27 -0400 Subject: [PATCH 4/4] split into 2 tests --- test/integration/test_job.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/integration/test_job.py b/test/integration/test_job.py index 3322f533c..fe5bd6130 100644 --- a/test/integration/test_job.py +++ b/test/integration/test_job.py @@ -119,9 +119,8 @@ def test_run_program_failed_ran_too_long(self, service): job.result() @run_integration_test - def test_run_program_failed_custom_max_execution_time(self, service): - """Test a program that failed with a custom max_execution_time.""" - # check that program max execution time is overridden + def test_run_program_override_max_execution_time(self, service): + """Test that the program max execution time is overridden.""" program_max_execution_time = 400 job_max_execution_time = 350 program_id = self._upload_program( @@ -134,8 +133,12 @@ def test_run_program_failed_custom_max_execution_time(self, service): self.assertEqual( job._api_client.job_get(job.job_id)["cost"], job_max_execution_time ) + + @run_integration_test + def test_invalid_max_execution_time_fails(self, service): + """Test that program fails when max_execution_time is less than 300.""" with self.assertRaises(IBMRuntimeError): - self._run_program(service, program_id=program_id, max_execution_time=1) + self._run_program(service, max_execution_time=299) @run_integration_test def test_run_program_failed_invalid_execution_time(self, service):