submit_azureml_pytest_5.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. def submit_experiment_to_azureml(test, test_folder, test_markers, junitxml,
  2. run_config, experiment):
  3. """
  4. Submitting the experiment to AzureML actually runs the script.
  5. Args:
  6. test (str) - pytest script, folder/test
  7. such as ./tests/ci/run_pytest.py
  8. test_folder (str) - folder where tests to run are stored,
  9. like ./tests/unit
  10. test_markers (str) - test markers used by pytest
  11. "not notebooks and not spark and not gpu"
  12. junitxml (str) - file of output summary of tests run
  13. note "--junitxml" is required as part
  14. of the string
  15. Example: "--junitxml reports/test-unit.xml"
  16. run_config - environment configuration
  17. experiment - instance of an Experiment, a collection of
  18. trials where each trial is a run.
  19. Return:
  20. run : AzureML run or trial
  21. """
  22. logger.debug('submit: testfolder {}'.format(test_folder))
  23. logger.debug('junitxml: {}'.format(junitxml))
  24. project_folder = "."
  25. script_run_config = ScriptRunConfig(source_directory=project_folder,
  26. script=test,
  27. run_config=run_config,
  28. arguments=["--testfolder",
  29. test_folder,
  30. "--testmarkers",
  31. test_markers,
  32. "--xmlname",
  33. junitxml]
  34. )
  35. run = experiment.submit(script_run_config)
  36. # waits only for configuration to complete
  37. run.wait_for_completion(show_output=True, wait_post_processing=True)
  38. # test logs can also be found on azure
  39. # go to azure portal to see log in azure ws and look for experiment name
  40. # and look for individual run
  41. logger.debug('files {}'.format(run.get_file_names))
  42. return run