Skip to content

Commit f0294b9

Browse files
authored
Merge pull request #100963 from trevorbye/master
environment schema for cli
2 parents c49c55e + 640630a commit f0294b9

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

articles/machine-learning/concept-environments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Environments can be created by:
3939
* Defining new `Environment` objects, either using a curated environment or by defining your own dependencies
4040
* Using existing `Environment` objects from your workspace. This allows for consistency and reproducibility with your dependencies
4141
* Importing from an existing Anaconda environment definition.
42+
* Using the Azure Machine Learning CLI
4243

4344
See the [how-to](how-to-use-environments.md#create-an-environment) for specific code examples. Environments are also easily managed through your workspace and include the following functionality:
4445

articles/machine-learning/how-to-use-environments.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,34 @@ service = Model.deploy(
344344

345345
This [example notebook](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/training/using-environments) expands upon concepts and methods demonstrated in this article.
346346

347+
## Create and manage environments with the CLI
348+
349+
The [Azure Machine Learning CLI](reference-azure-machine-learning-cli.md) mirrors the majority of the functionality of the Python SDK, and can be used for environment creation and management. The following commands demonstrate basic functionality.
350+
351+
The following command scaffolds the files for a default environment definition in the specified directory. These files are JSON files that are similar in function to the corresponding class in the SDK, and can be used to create new environments with custom settings.
352+
353+
```azurecli-interactive
354+
az ml environment scaffold -n myenv -d myenvdir
355+
```
356+
357+
Run the following command to register an environment from a specified directory.
358+
359+
```azurecli-interactive
360+
az ml environment register -d myenvdir
361+
```
362+
363+
Running the following command will list all registered environments.
364+
365+
```azurecli-interactive
366+
az ml environment list
367+
```
368+
369+
Download a registered environment with the following command.
370+
371+
```azurecli-interactive
372+
az ml environment download -n myenv -d downloaddir
373+
```
374+
347375
## Next steps
348376

349377
* [Tutorial: Train a model](tutorial-train-models-with-aml.md) uses a managed compute target to train a model.

articles/machine-learning/reference-azure-machine-learning-cli.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,65 @@ The following commands demonstrate how to create, register, and list Azure Machi
259259
260260
For more information, see [az ml environment download](https://docs.microsoft.com/cli/azure/ext/azure-cli-ml/ml/environment?view=azure-cli-latest#ext-azure-cli-ml-az-ml-environment-download).
261261
262+
### Environment configuration schema
263+
264+
If you used the `az ml environment scaffold` command, it generates a template `azureml_environment.json` file that can be modified and used to create custom environment configurations with the CLI. The top level object loosely maps to the [`Environment`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.environment(class)?view=azure-ml-py) class in the Python SDK.
265+
266+
```json
267+
{
268+
"name": "testenv",
269+
"version": null,
270+
"environmentVariables": {
271+
"EXAMPLE_ENV_VAR": "EXAMPLE_VALUE"
272+
},
273+
"python": {
274+
"userManagedDependencies": false,
275+
"interpreterPath": "python",
276+
"condaDependenciesFile": null,
277+
"baseCondaEnvironment": null
278+
},
279+
"docker": {
280+
"enabled": false,
281+
"baseImage": "mcr.microsoft.com/azureml/base:intelmpi2018.3-ubuntu16.04",
282+
"baseDockerfile": null,
283+
"sharedVolumes": true,
284+
"shmSize": "2g",
285+
"arguments": [],
286+
"baseImageRegistry": {
287+
"address": null,
288+
"username": null,
289+
"password": null
290+
}
291+
},
292+
"spark": {
293+
"repositories": [],
294+
"packages": [],
295+
"precachePackages": true
296+
},
297+
"databricks": {
298+
"mavenLibraries": [],
299+
"pypiLibraries": [],
300+
"rcranLibraries": [],
301+
"jarLibraries": [],
302+
"eggLibraries": []
303+
},
304+
"inferencingStackVersion": null
305+
}
306+
```
307+
308+
The following table details each top-level field in the JSON file, it's type, and a description. If an object type is linked to a class from the Python SDK, there is a loose 1:1 match between each JSON field and the public variable name in the Python class. In some cases the field may map to a constructor argument rather than a class variable. For example, the `environmentVariables` field maps to the `environment_variables` variable in the [`Environment`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.environment(class)?view=azure-ml-py) class.
309+
310+
| JSON field | Type | Description |
311+
|---|---|---|
312+
| `name` | `string` | Name of the environment. Do not start name with **Microsoft** or **AzureML**. |
313+
| `version` | `string` | Version of the environment. |
314+
| `environmentVariables` | `{string: string}` | A hash-map of environment variable names and values. |
315+
| `python` | [`PythonSection`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.environment.pythonsection?view=azure-ml-py) | Object that defines the Python environment and interpreter to use on target compute resource. |
316+
| `docker` | [`DockerSection`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.environment.dockersection?view=azure-ml-py) | Defines settings to customize the Docker image built to the environment's specifications. |
317+
| `spark` | [`SparkSection`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.environment.sparksection?view=azure-ml-py) | The section configures Spark settings. It is only used when framework is set to PySpark. |
318+
| `databricks` | [`DatabricksSection`](https://docs.microsoft.com/python/api/azureml-core/azureml.core.databricks.databrickssection?view=azure-ml-py) | Configures Databricks library dependencies. |
319+
| `inferencingStackVersion` | `string` | Specifies the inferencing stack version added to the image. To avoid adding an inferencing stack, leave this field `null`. Valid value: "latest". |
320+
262321
## ML pipeline management
263322

264323
The following commands demonstrate how to work with machine learning pipelines:

0 commit comments

Comments
 (0)