Skip to content

Commit e78077d

Browse files
adam-grofeAdam Grofe
andauthored
Modify dft tests to use qcschema instead of xyz. (#8577)
Co-authored-by: Adam Grofe <[email protected]>
1 parent 5014bfa commit e78077d

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"schema_name": "qcschema_input",
3+
"molecule": {
4+
"symbols": [ "H", "H", "O" ],
5+
"geometry": [ 0.0, 0.9259658, -1.492884, 0.0, 0.9259658, 1.4928836, 0.0, -0.226767, 0.0 ]
6+
},
7+
"driver": "NotImplemented",
8+
"model": {
9+
"method": "b3lyp",
10+
"basis": "def2-svp"
11+
}
12+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"schema_name": "qcschema_optimization_input",
3+
"schema_version": 1,
4+
"initial_molecule": {
5+
"extras": {},
6+
"symbols": [
7+
"C",
8+
"H",
9+
"H",
10+
"H",
11+
"O",
12+
"H"
13+
],
14+
"geometry": [
15+
-0.8756635443962137,
16+
0.25558568601582665,
17+
-11.45827667880426,
18+
-0.4978438350221539,
19+
-1.205215593021271,
20+
-12.8661420546337,
21+
-2.863990058618547,
22+
0.8281280629070027,
23+
-11.609419376142775,
24+
0.3380882421810811,
25+
1.893655772280663,
26+
-11.845096394227674,
27+
-0.349613980691185,
28+
-0.8008275791386757,
29+
-9.057920041103289,
30+
-0.6117419460857874,
31+
0.4602802397698158,
32+
-7.766292837153531
33+
]
34+
},
35+
"input_specification": {
36+
"model": {
37+
"method": "b3lyp",
38+
"basis": "def2-svp"
39+
},
40+
"keywords": {
41+
"max_scf_steps": 3
42+
},
43+
"driver": "gradient"
44+
}
45+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"schema_name": "qcschema_input",
3+
"molecule": {
4+
"symbols": [ "H", "H", "O" ],
5+
"geometry": [ 0.0, 0.9259658, -1.492884, 0.0, 0.9259658, 1.4928836, 0.0, -0.226767, 0.0 ]
6+
},
7+
"driver": "gradient",
8+
"model": {
9+
"method": "b3lyp",
10+
"basis": "def2-svp"
11+
}
12+
}

src/quantum/azext_quantum/tests/latest/test_quantum_jobs.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,27 +280,26 @@ def test_submit_dft(self):
280280
self.cmd(f"az quantum workspace set -g {test_resource_group} -w {test_workspace_temp} -l {test_location}")
281281

282282
# Run a "microsoft.dft" job to test that successful job returns proper output
283-
results = self.cmd("az quantum run -t microsoft.dft --job-input-format microsoft.xyz.v1 --job-output-format microsoft.dft-results.v1 --job-input-file src/quantum/azext_quantum/tests/latest/input_data/dft_molecule_success.xyz --job-params {{\\\"tasks\\\":[{{\\\"taskType\\\":\\\"spe\\\",\\\"basisSet\\\":{{\\\"name\\\":\\\"def2-svp\\\",\\\"cartesian\\\":false}},\\\"xcFunctional\\\":{{\\\"name\\\":\\\"m06-2x\\\",\\\"gridLevel\\\":4}},\\\"scf\\\":{{\\\"method\\\":\\\"rks\\\",\\\"maxSteps\\\":100,\\\"convergeThreshold\\\":1e-8}}}}]}} -o json").get_output_in_json()
283+
results = self.cmd("az quantum run -t microsoft.dft --job-input-format microsoft.qc-schema.v1 --job-output-format microsoft.dft-results.v1 --job-input-file src/quantum/azext_quantum/tests/latest/input_data/dft_molecule_success.json -o json").get_output_in_json()
284284
self.assertIsNotNone(results["results"])
285285
self.assertTrue(len(results["results"]) == 1)
286286
self.assertTrue(results["results"][0]["success"])
287287

288288
# Run a "microsoft.dft" job to test that failed run returns "Job"-object if job didn't produce any output
289289
# In the test case below the run doesn't produce any output since the job fails on input parameter validation (i.e. taskType: "invalidTask")
290-
results = self.cmd("az quantum run -t microsoft.dft --job-input-format microsoft.xyz.v1 --job-output-format microsoft.dft-results.v1 --job-input-file src/quantum/azext_quantum/tests/latest/input_data/dft_molecule_success.xyz --job-params {{\\\"tasks\\\":[{{\\\"taskType\\\":\\\"invalidTask\\\",\\\"basisSet\\\":{{\\\"name\\\":\\\"def2-svp\\\",\\\"cartesian\\\":false}},\\\"xcFunctional\\\":{{\\\"name\\\":\\\"m06-2x\\\",\\\"gridLevel\\\":4}},\\\"scf\\\":{{\\\"method\\\":\\\"rks\\\",\\\"maxSteps\\\":100,\\\"convergeThreshold\\\":1e-8}}}}]}} -o json").get_output_in_json()
291-
self.assertEqual("Job", results["itemType"]) # the object is a "Job"-object
292-
self.assertEqual("Failed", results["status"])
293-
self.assertIsNotNone(results["errorData"])
294-
self.assertEqual("InvalidInputData", results["errorData"]["code"])
295-
self.assertEqual("microsoft.dft", results["target"])
290+
results = self.cmd("az quantum run -t microsoft.dft --job-input-format microsoft.qc-schema.v1 --job-output-format microsoft.dft-results.v1 --job-input-file src/quantum/azext_quantum/tests/latest/input_data/dft_molecule_failure_bad_params.json -o json").get_output_in_json()
291+
self.assertIsNotNone(results["results"])
292+
self.assertTrue(len(results["results"]) == 1)
293+
self.assertFalse(results["results"][0]["success"])
294+
self.assertTrue(results["results"][0]["error"]["error_type"] == "input_error")
296295

297296
# Run a "microsoft.dft" job to test that failed run returns output if it was produced by the job
298297
# In the test case below the job fails to converge in "maxSteps", but it still produces the output with a detailed message
299-
results = self.cmd("az quantum run -t microsoft.dft --job-input-format microsoft.xyz.v1 --job-output-format microsoft.dft-results.v1 --job-input-file src/quantum/azext_quantum/tests/latest/input_data/dft_molecule_failure.xyz --job-params {{\\\"tasks\\\":[{{\\\"taskType\\\":\\\"go\\\",\\\"basisSet\\\":{{\\\"name\\\":\\\"def2-tzvpp\\\",\\\"cartesian\\\":false}},\\\"xcFunctional\\\":{{\\\"name\\\":\\\"m06-2x\\\",\\\"gridLevel\\\":4}},\\\"scf\\\":{{\\\"method\\\":\\\"rks\\\",\\\"maxSteps\\\":5,\\\"convergeThreshold\\\":1e-8}},\\\"geometryOptimization\\\":{{\\\"gdiis\\\":false}}}}]}} -o json").get_output_in_json()
300-
self.assertTrue("itemType" not in results or results["itemType"] != "Job") # the object is not a "Job"-object
298+
results = self.cmd("az quantum run -t microsoft.dft --job-input-format microsoft.qc-schema.v1 --job-output-format microsoft.dft-results.v1 --job-input-file src/quantum/azext_quantum/tests/latest/input_data/dft_molecule_failure_no_convergence.json -o json").get_output_in_json()
301299
self.assertIsNotNone(results["results"])
302300
self.assertTrue(len(results["results"]) == 1)
303301
self.assertFalse(results["results"][0]["success"])
302+
self.assertTrue(results["results"][0]["error"]["error_type"] == "convergence_error")
304303

305304
self.cmd(f'az quantum workspace delete -g {test_resource_group} -w {test_workspace_temp}')
306305

0 commit comments

Comments
 (0)