We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add all items required for making the repository public
Ensure that all files have copyright notices, and that editors are set up to automatically insert them (PyCharm does it correctly on InnerEye)

You must run the following source code analysis tools:
CredScan
CodeQL (Semmle)
Component Governance Detection
The easiest way to run these tools is to add thems in your build pipeline in a Microsoft-managed Azure DevOps account.

For CodeQL, please ensure the following (detailed instructions for CodeQL can be found here):
Select the source code language in the CodeQL task.
If your application was developed using multiple languages, add multiple CodeQL tasks.
Define the build variable LGTM.UploadSnapshot=true.
Configure the build to allow scripts to access OAuth token.
If the code is hosted in Github, create Azure DevOps PAT token with code read scope for dev.azure.com/Microsoft (or ‘all’) organization and set the local task variable System_AccessToken with it. (Note: This only works for YAML-based pipelines.)
Review security issues by navigating to semmleportal.azurewebsites.net/lookup. It may take up to one day to process results.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/health/azure/datasets.py`
Content:
```
1 import logging
2 from pathlib import Path
3 from typing import List, Optional, Union
4 
5 from azureml.core import Dataset, Datastore, Workspace
6 from azureml.data import FileDataset, OutputFileDatasetConfig
7 from azureml.data.dataset_consumption_config import DatasetConsumptionConfig
8 
9 
10 def get_datastore(workspace: Workspace, datastore_name: str) -> Datastore:
11     """
12     Retrieves a datastore of a given name from an AzureML workspace. The datastore_name argument can be omitted if
13     the workspace only contains a single datastore. Raises a ValueError if there is no datastore of the given name.
14     :param workspace: The AzureML workspace to read from.
15     :param datastore_name: The name of the datastore to retrieve.
16     :return: An AzureML datastore.
17     """
18     datastores = workspace.datastores
19     existing_stores = list(datastores.keys())
20     if not datastore_name:
21         if len(existing_stores) == 1:
22             return datastores[existing_stores[0]]
23         raise ValueError("No datastore name provided. This is only possible if the workspace has a single datastore. "
24                          f"However, the workspace has {len(existing_stores)} datastores: {existing_stores}")
25     if datastore_name in datastores:
26         return datastores[datastore_name]
27     raise ValueError(f"Datastore {datastore_name} was not found in the workspace. Existing datastores: "
28                      f"{existing_stores}")
29 
30 
31 def get_or_create_dataset(workspace: Workspace, datastore_name: str, dataset_name: str) -> FileDataset:
32     """
33     Looks in the AzureML datastore for a dataset of the given name. If there is no such dataset, a dataset is
34     created and registered, assuming that the files are in a folder that has the same name as the dataset.
35     For example, if dataset_name is 'foo', then the 'foo' dataset should be pointing to the folder
36     <container_root>/datasets/dataset_name/
37     """
38     if not dataset_name:
39         raise ValueError("No dataset name provided.")
40     try:
41         logging.info(f"Trying to retrieve AzureML Dataset '{dataset_name}'")
42         azureml_dataset = Dataset.get_by_name(workspace, name=dataset_name)
43         logging.info("Dataset found.")
44     except Exception:
45         logging.info(f"Retrieving datastore '{datastore_name}' from AzureML workspace")
46         datastore = get_datastore(workspace, datastore_name)
47         logging.info(f"Creating a new dataset from data in folder '{dataset_name}' in the datastore")
48         # Ensure that there is a / at the end of the file path, otherwise folder that share a prefix could create
49         # trouble (for example, folders foo and foo_bar exist, and I'm trying to create a dataset from "foo")
50         azureml_dataset = Dataset.File.from_files(path=(datastore, dataset_name + "/"))
51         logging.info("Registering the dataset for future use.")
52         azureml_dataset.register(workspace, name=dataset_name)
53     return azureml_dataset
54 
55 
56 def _input_dataset_key(index: int) -> str:
57     return f"INPUT_{index}"
58 
59 
60 def _output_dataset_key(index: int) -> str:
61     return f"OUTPUT_{index}"
62 
63 
64 class DatasetConfig:
65     """
66     Contains information to use AzureML datasets as inputs or outputs.
67     """
68 
69     def __init__(self,
70                  name: str,
71                  datastore: str = "",
72                  version: Optional[int] = None,
73                  use_mounting: Optional[bool] = None,
74                  target_folder: str = "",
75                  local_folder: Optional[Path] = None):
76         """
77         Creates a new configuration for using an AzureML dataset.
78         :param name: The name of the dataset, as it was registered in the AzureML workspace. For output datasets,
79         this will be the name given to the newly created dataset.
80         :param datastore: The name of the AzureML datastore that holds the dataset. This can be empty if the AzureML
81         workspace has only a single datastore, or if the default datastore should be used.
82         :param version: The version of the dataset that should be used. This is only used for input datasets.
83         If the version is not specified, the latest version will be used.
84         :param use_mounting: If True, the dataset will be "mounted", that is, individual files will be read
85         or written on-demand over the network. If False, the dataset will be fully downloaded before the job starts,
86         respectively fully uploaded at job end for output datasets.
87         Defaults: False (downloading) for datasets that are script inputs, True (mounting) for datasets that are script
88         outputs.
89         :param target_folder: The folder into which the dataset should be downloaded or mounted. If left empty, a
90         random folder on /tmp will be chosen.
91         :param local_folder: The folder on the local machine at which the dataset is available. This
92         is used only for runs outside of AzureML.
93         """
94         # This class would be a good candidate for a dataclass, but having an explicit constructor makes
95         # documentation tools in the editor work nicer.
96         name = name.strip()
97         if not name:
98             raise ValueError("The name of the dataset must be a non-empty string.")
99         self.name = name
100         self.datastore = datastore
101         self.version = version
102         self.use_mounting = use_mounting
103         self.target_folder = target_folder
104         self.local_folder = local_folder
105 
106     def to_input_dataset(self,
107                          workspace: Workspace,
108                          dataset_index: int) -> DatasetConsumptionConfig:
109         """
110         Creates a configuration for using an AzureML dataset inside of an AzureML run. This will make the AzureML
111         dataset with given name available as a named input, using INPUT_0 as the key for dataset index 0.
112         :param workspace: The AzureML workspace to read from.
113         :param dataset_index: Suffix for using datasets as named inputs, the dataset will be marked INPUT_{index}
114         """
115         status = f"Dataset {self.name} (index {dataset_index}) will be "
116         azureml_dataset = get_or_create_dataset(workspace=workspace,
117                                                 dataset_name=self.name,
118                                                 datastore_name=self.datastore)
119         named_input = azureml_dataset.as_named_input(_input_dataset_key(index=dataset_index))
120         path_on_compute = self.target_folder or None
121         use_mounting = False if self.use_mounting is None else self.use_mounting
122         if use_mounting:
123             status += "mounted at "
124             result = named_input.as_mount(path_on_compute)
125         else:
126             status += "downloaded to "
127             result = named_input.as_download(path_on_compute)
128         if path_on_compute:
129             status += f"{path_on_compute}."
130         else:
131             status += "a randomly chosen folder."
132         logging.info(status)
133         return result
134 
135     def to_output_dataset(self,
136                           workspace: Workspace,
137                           dataset_index: int) -> OutputFileDatasetConfig:
138         """
139         Creates a configuration to write a script output to an AzureML dataset. The name and datastore of this new
140         dataset will be taken from the present object.
141         :param workspace: The AzureML workspace to read from.
142         :param dataset_index: Suffix for using datasets as named inputs, the dataset will be marked OUTPUT_{index}
143         :return:
144         """
145         status = f"Output dataset {self.name} (index {dataset_index}) will be "
146         datastore = get_datastore(workspace, self.datastore)
147         dataset = OutputFileDatasetConfig(name=_output_dataset_key(index=dataset_index),
148                                           destination=(datastore, self.name + "/"))
149         # TODO: Can we get tags into here too?
150         dataset = dataset.register_on_complete(name=self.name)
151         if self.target_folder:
152             raise ValueError("Output datasets can't have a target_folder set.")
153         use_mounting = True if self.use_mounting is None else self.use_mounting
154         if use_mounting:
155             status += "uploaded while the job runs."
156             result = dataset.as_mount()
157         else:
158             status += "uploaded when the job completes."
159             result = dataset.as_upload()
160         logging.info(status)
161         return result
162 
163 
164 StrOrDatasetConfig = Union[str, DatasetConfig]
165 
166 
167 def _replace_string_datasets(datasets: List[StrOrDatasetConfig],
168                              default_datastore_name: str) -> List[DatasetConfig]:
169     """
170     Processes a list of input or output datasets. All entries in the list that are strings are turned into
171     DatasetConfig objects, using the string as the dataset name, and pointing to the default datastore.
172     :param datasets: A list of datasets, each given either as a string or a DatasetConfig object.
173     :param default_datastore_name: The datastore to use for all datasets that are only specified via their name.
174     :return: A list of DatasetConfig objects, in the same order as the input list.
175     """
176     return [DatasetConfig(name=d, datastore=default_datastore_name) if isinstance(d, str) else d
177             for d in datasets]
178
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/health/azure/datasets.py b/src/health/azure/datasets.py
--- a/src/health/azure/datasets.py
+++ b/src/health/azure/datasets.py
@@ -1,3 +1,7 @@
+#  ------------------------------------------------------------------------------------------
+#  Copyright (c) Microsoft Corporation. All rights reserved.
+#  Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+#  ------------------------------------------------------------------------------------------
 import logging
 from pathlib import Path
 from typing import List, Optional, Union

{"golden_diff": "diff --git a/src/health/azure/datasets.py b/src/health/azure/datasets.py\n--- a/src/health/azure/datasets.py\n+++ b/src/health/azure/datasets.py\n@@ -1,3 +1,7 @@\n+#  ------------------------------------------------------------------------------------------\n+#  Copyright (c) Microsoft Corporation. All rights reserved.\n+#  Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.\n+#  ------------------------------------------------------------------------------------------\n import logging\n from pathlib import Path\n from typing import List, Optional, Union\n", "issue": "Add all items required for making the repository public\nEnsure that all files have copyright notices, and that editors are set up to automatically insert them (PyCharm does it correctly on InnerEye)\r\n\r\nYou must run the following source code analysis tools:\r\nCredScan\r\nCodeQL (Semmle)\r\nComponent Governance Detection\r\nThe easiest way to run these tools is to add thems in your build pipeline in a Microsoft-managed Azure DevOps account.\r\n\r\nFor CodeQL, please ensure the following (detailed instructions for CodeQL can be found here):\r\nSelect the source code language in the CodeQL task.\r\nIf your application was developed using multiple languages, add multiple CodeQL tasks.\r\nDefine the build variable LGTM.UploadSnapshot=true.\r\nConfigure the build to allow scripts to access OAuth token.\r\nIf the code is hosted in Github, create Azure DevOps PAT token with code read scope for dev.azure.com/Microsoft (or \u2018all\u2019) organization and set the local task variable System_AccessToken with it. (Note: This only works for YAML-based pipelines.)\r\nReview security issues by navigating to semmleportal.azurewebsites.net/lookup. It may take up to one day to process results.\n", "before_files": [{"content": "import logging\nfrom pathlib import Path\nfrom typing import List, Optional, Union\n\nfrom azureml.core import Dataset, Datastore, Workspace\nfrom azureml.data import FileDataset, OutputFileDatasetConfig\nfrom azureml.data.dataset_consumption_config import DatasetConsumptionConfig\n\n\ndef get_datastore(workspace: Workspace, datastore_name: str) -> Datastore:\n    \"\"\"\n    Retrieves a datastore of a given name from an AzureML workspace. The datastore_name argument can be omitted if\n    the workspace only contains a single datastore. Raises a ValueError if there is no datastore of the given name.\n    :param workspace: The AzureML workspace to read from.\n    :param datastore_name: The name of the datastore to retrieve.\n    :return: An AzureML datastore.\n    \"\"\"\n    datastores = workspace.datastores\n    existing_stores = list(datastores.keys())\n    if not datastore_name:\n        if len(existing_stores) == 1:\n            return datastores[existing_stores[0]]\n        raise ValueError(\"No datastore name provided. This is only possible if the workspace has a single datastore. \"\n                         f\"However, the workspace has {len(existing_stores)} datastores: {existing_stores}\")\n    if datastore_name in datastores:\n        return datastores[datastore_name]\n    raise ValueError(f\"Datastore {datastore_name} was not found in the workspace. Existing datastores: \"\n                     f\"{existing_stores}\")\n\n\ndef get_or_create_dataset(workspace: Workspace, datastore_name: str, dataset_name: str) -> FileDataset:\n    \"\"\"\n    Looks in the AzureML datastore for a dataset of the given name. If there is no such dataset, a dataset is\n    created and registered, assuming that the files are in a folder that has the same name as the dataset.\n    For example, if dataset_name is 'foo', then the 'foo' dataset should be pointing to the folder\n    <container_root>/datasets/dataset_name/\n    \"\"\"\n    if not dataset_name:\n        raise ValueError(\"No dataset name provided.\")\n    try:\n        logging.info(f\"Trying to retrieve AzureML Dataset '{dataset_name}'\")\n        azureml_dataset = Dataset.get_by_name(workspace, name=dataset_name)\n        logging.info(\"Dataset found.\")\n    except Exception:\n        logging.info(f\"Retrieving datastore '{datastore_name}' from AzureML workspace\")\n        datastore = get_datastore(workspace, datastore_name)\n        logging.info(f\"Creating a new dataset from data in folder '{dataset_name}' in the datastore\")\n        # Ensure that there is a / at the end of the file path, otherwise folder that share a prefix could create\n        # trouble (for example, folders foo and foo_bar exist, and I'm trying to create a dataset from \"foo\")\n        azureml_dataset = Dataset.File.from_files(path=(datastore, dataset_name + \"/\"))\n        logging.info(\"Registering the dataset for future use.\")\n        azureml_dataset.register(workspace, name=dataset_name)\n    return azureml_dataset\n\n\ndef _input_dataset_key(index: int) -> str:\n    return f\"INPUT_{index}\"\n\n\ndef _output_dataset_key(index: int) -> str:\n    return f\"OUTPUT_{index}\"\n\n\nclass DatasetConfig:\n    \"\"\"\n    Contains information to use AzureML datasets as inputs or outputs.\n    \"\"\"\n\n    def __init__(self,\n                 name: str,\n                 datastore: str = \"\",\n                 version: Optional[int] = None,\n                 use_mounting: Optional[bool] = None,\n                 target_folder: str = \"\",\n                 local_folder: Optional[Path] = None):\n        \"\"\"\n        Creates a new configuration for using an AzureML dataset.\n        :param name: The name of the dataset, as it was registered in the AzureML workspace. For output datasets,\n        this will be the name given to the newly created dataset.\n        :param datastore: The name of the AzureML datastore that holds the dataset. This can be empty if the AzureML\n        workspace has only a single datastore, or if the default datastore should be used.\n        :param version: The version of the dataset that should be used. This is only used for input datasets.\n        If the version is not specified, the latest version will be used.\n        :param use_mounting: If True, the dataset will be \"mounted\", that is, individual files will be read\n        or written on-demand over the network. If False, the dataset will be fully downloaded before the job starts,\n        respectively fully uploaded at job end for output datasets.\n        Defaults: False (downloading) for datasets that are script inputs, True (mounting) for datasets that are script\n        outputs.\n        :param target_folder: The folder into which the dataset should be downloaded or mounted. If left empty, a\n        random folder on /tmp will be chosen.\n        :param local_folder: The folder on the local machine at which the dataset is available. This\n        is used only for runs outside of AzureML.\n        \"\"\"\n        # This class would be a good candidate for a dataclass, but having an explicit constructor makes\n        # documentation tools in the editor work nicer.\n        name = name.strip()\n        if not name:\n            raise ValueError(\"The name of the dataset must be a non-empty string.\")\n        self.name = name\n        self.datastore = datastore\n        self.version = version\n        self.use_mounting = use_mounting\n        self.target_folder = target_folder\n        self.local_folder = local_folder\n\n    def to_input_dataset(self,\n                         workspace: Workspace,\n                         dataset_index: int) -> DatasetConsumptionConfig:\n        \"\"\"\n        Creates a configuration for using an AzureML dataset inside of an AzureML run. This will make the AzureML\n        dataset with given name available as a named input, using INPUT_0 as the key for dataset index 0.\n        :param workspace: The AzureML workspace to read from.\n        :param dataset_index: Suffix for using datasets as named inputs, the dataset will be marked INPUT_{index}\n        \"\"\"\n        status = f\"Dataset {self.name} (index {dataset_index}) will be \"\n        azureml_dataset = get_or_create_dataset(workspace=workspace,\n                                                dataset_name=self.name,\n                                                datastore_name=self.datastore)\n        named_input = azureml_dataset.as_named_input(_input_dataset_key(index=dataset_index))\n        path_on_compute = self.target_folder or None\n        use_mounting = False if self.use_mounting is None else self.use_mounting\n        if use_mounting:\n            status += \"mounted at \"\n            result = named_input.as_mount(path_on_compute)\n        else:\n            status += \"downloaded to \"\n            result = named_input.as_download(path_on_compute)\n        if path_on_compute:\n            status += f\"{path_on_compute}.\"\n        else:\n            status += \"a randomly chosen folder.\"\n        logging.info(status)\n        return result\n\n    def to_output_dataset(self,\n                          workspace: Workspace,\n                          dataset_index: int) -> OutputFileDatasetConfig:\n        \"\"\"\n        Creates a configuration to write a script output to an AzureML dataset. The name and datastore of this new\n        dataset will be taken from the present object.\n        :param workspace: The AzureML workspace to read from.\n        :param dataset_index: Suffix for using datasets as named inputs, the dataset will be marked OUTPUT_{index}\n        :return:\n        \"\"\"\n        status = f\"Output dataset {self.name} (index {dataset_index}) will be \"\n        datastore = get_datastore(workspace, self.datastore)\n        dataset = OutputFileDatasetConfig(name=_output_dataset_key(index=dataset_index),\n                                          destination=(datastore, self.name + \"/\"))\n        # TODO: Can we get tags into here too?\n        dataset = dataset.register_on_complete(name=self.name)\n        if self.target_folder:\n            raise ValueError(\"Output datasets can't have a target_folder set.\")\n        use_mounting = True if self.use_mounting is None else self.use_mounting\n        if use_mounting:\n            status += \"uploaded while the job runs.\"\n            result = dataset.as_mount()\n        else:\n            status += \"uploaded when the job completes.\"\n            result = dataset.as_upload()\n        logging.info(status)\n        return result\n\n\nStrOrDatasetConfig = Union[str, DatasetConfig]\n\n\ndef _replace_string_datasets(datasets: List[StrOrDatasetConfig],\n                             default_datastore_name: str) -> List[DatasetConfig]:\n    \"\"\"\n    Processes a list of input or output datasets. All entries in the list that are strings are turned into\n    DatasetConfig objects, using the string as the dataset name, and pointing to the default datastore.\n    :param datasets: A list of datasets, each given either as a string or a DatasetConfig object.\n    :param default_datastore_name: The datastore to use for all datasets that are only specified via their name.\n    :return: A list of DatasetConfig objects, in the same order as the input list.\n    \"\"\"\n    return [DatasetConfig(name=d, datastore=default_datastore_name) if isinstance(d, str) else d\n            for d in datasets]\n", "path": "src/health/azure/datasets.py"}], "after_files": [{"content": "#  ------------------------------------------------------------------------------------------\n#  Copyright (c) Microsoft Corporation. All rights reserved.\n#  Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.\n#  ------------------------------------------------------------------------------------------\nimport logging\nfrom pathlib import Path\nfrom typing import List, Optional, Union\n\nfrom azureml.core import Dataset, Datastore, Workspace\nfrom azureml.data import FileDataset, OutputFileDatasetConfig\nfrom azureml.data.dataset_consumption_config import DatasetConsumptionConfig\n\n\ndef get_datastore(workspace: Workspace, datastore_name: str) -> Datastore:\n    \"\"\"\n    Retrieves a datastore of a given name from an AzureML workspace. The datastore_name argument can be omitted if\n    the workspace only contains a single datastore. Raises a ValueError if there is no datastore of the given name.\n    :param workspace: The AzureML workspace to read from.\n    :param datastore_name: The name of the datastore to retrieve.\n    :return: An AzureML datastore.\n    \"\"\"\n    datastores = workspace.datastores\n    existing_stores = list(datastores.keys())\n    if not datastore_name:\n        if len(existing_stores) == 1:\n            return datastores[existing_stores[0]]\n        raise ValueError(\"No datastore name provided. This is only possible if the workspace has a single datastore. \"\n                         f\"However, the workspace has {len(existing_stores)} datastores: {existing_stores}\")\n    if datastore_name in datastores:\n        return datastores[datastore_name]\n    raise ValueError(f\"Datastore {datastore_name} was not found in the workspace. Existing datastores: \"\n                     f\"{existing_stores}\")\n\n\ndef get_or_create_dataset(workspace: Workspace, datastore_name: str, dataset_name: str) -> FileDataset:\n    \"\"\"\n    Looks in the AzureML datastore for a dataset of the given name. If there is no such dataset, a dataset is\n    created and registered, assuming that the files are in a folder that has the same name as the dataset.\n    For example, if dataset_name is 'foo', then the 'foo' dataset should be pointing to the folder\n    <container_root>/datasets/dataset_name/\n    \"\"\"\n    if not dataset_name:\n        raise ValueError(\"No dataset name provided.\")\n    try:\n        logging.info(f\"Trying to retrieve AzureML Dataset '{dataset_name}'\")\n        azureml_dataset = Dataset.get_by_name(workspace, name=dataset_name)\n        logging.info(\"Dataset found.\")\n    except Exception:\n        logging.info(f\"Retrieving datastore '{datastore_name}' from AzureML workspace\")\n        datastore = get_datastore(workspace, datastore_name)\n        logging.info(f\"Creating a new dataset from data in folder '{dataset_name}' in the datastore\")\n        # Ensure that there is a / at the end of the file path, otherwise folder that share a prefix could create\n        # trouble (for example, folders foo and foo_bar exist, and I'm trying to create a dataset from \"foo\")\n        azureml_dataset = Dataset.File.from_files(path=(datastore, dataset_name + \"/\"))\n        logging.info(\"Registering the dataset for future use.\")\n        azureml_dataset.register(workspace, name=dataset_name)\n    return azureml_dataset\n\n\ndef _input_dataset_key(index: int) -> str:\n    return f\"INPUT_{index}\"\n\n\ndef _output_dataset_key(index: int) -> str:\n    return f\"OUTPUT_{index}\"\n\n\nclass DatasetConfig:\n    \"\"\"\n    Contains information to use AzureML datasets as inputs or outputs.\n    \"\"\"\n\n    def __init__(self,\n                 name: str,\n                 datastore: str = \"\",\n                 version: Optional[int] = None,\n                 use_mounting: Optional[bool] = None,\n                 target_folder: str = \"\",\n                 local_folder: Optional[Path] = None):\n        \"\"\"\n        Creates a new configuration for using an AzureML dataset.\n        :param name: The name of the dataset, as it was registered in the AzureML workspace. For output datasets,\n        this will be the name given to the newly created dataset.\n        :param datastore: The name of the AzureML datastore that holds the dataset. This can be empty if the AzureML\n        workspace has only a single datastore, or if the default datastore should be used.\n        :param version: The version of the dataset that should be used. This is only used for input datasets.\n        If the version is not specified, the latest version will be used.\n        :param use_mounting: If True, the dataset will be \"mounted\", that is, individual files will be read\n        or written on-demand over the network. If False, the dataset will be fully downloaded before the job starts,\n        respectively fully uploaded at job end for output datasets.\n        Defaults: False (downloading) for datasets that are script inputs, True (mounting) for datasets that are script\n        outputs.\n        :param target_folder: The folder into which the dataset should be downloaded or mounted. If left empty, a\n        random folder on /tmp will be chosen.\n        :param local_folder: The folder on the local machine at which the dataset is available. This\n        is used only for runs outside of AzureML.\n        \"\"\"\n        # This class would be a good candidate for a dataclass, but having an explicit constructor makes\n        # documentation tools in the editor work nicer.\n        name = name.strip()\n        if not name:\n            raise ValueError(\"The name of the dataset must be a non-empty string.\")\n        self.name = name\n        self.datastore = datastore\n        self.version = version\n        self.use_mounting = use_mounting\n        self.target_folder = target_folder\n        self.local_folder = local_folder\n\n    def to_input_dataset(self,\n                         workspace: Workspace,\n                         dataset_index: int) -> DatasetConsumptionConfig:\n        \"\"\"\n        Creates a configuration for using an AzureML dataset inside of an AzureML run. This will make the AzureML\n        dataset with given name available as a named input, using INPUT_0 as the key for dataset index 0.\n        :param workspace: The AzureML workspace to read from.\n        :param dataset_index: Suffix for using datasets as named inputs, the dataset will be marked INPUT_{index}\n        \"\"\"\n        status = f\"Dataset {self.name} (index {dataset_index}) will be \"\n        azureml_dataset = get_or_create_dataset(workspace=workspace,\n                                                dataset_name=self.name,\n                                                datastore_name=self.datastore)\n        named_input = azureml_dataset.as_named_input(_input_dataset_key(index=dataset_index))\n        path_on_compute = self.target_folder or None\n        use_mounting = False if self.use_mounting is None else self.use_mounting\n        if use_mounting:\n            status += \"mounted at \"\n            result = named_input.as_mount(path_on_compute)\n        else:\n            status += \"downloaded to \"\n            result = named_input.as_download(path_on_compute)\n        if path_on_compute:\n            status += f\"{path_on_compute}.\"\n        else:\n            status += \"a randomly chosen folder.\"\n        logging.info(status)\n        return result\n\n    def to_output_dataset(self,\n                          workspace: Workspace,\n                          dataset_index: int) -> OutputFileDatasetConfig:\n        \"\"\"\n        Creates a configuration to write a script output to an AzureML dataset. The name and datastore of this new\n        dataset will be taken from the present object.\n        :param workspace: The AzureML workspace to read from.\n        :param dataset_index: Suffix for using datasets as named inputs, the dataset will be marked OUTPUT_{index}\n        :return:\n        \"\"\"\n        status = f\"Output dataset {self.name} (index {dataset_index}) will be \"\n        datastore = get_datastore(workspace, self.datastore)\n        dataset = OutputFileDatasetConfig(name=_output_dataset_key(index=dataset_index),\n                                          destination=(datastore, self.name + \"/\"))\n        # TODO: Can we get tags into here too?\n        dataset = dataset.register_on_complete(name=self.name)\n        if self.target_folder:\n            raise ValueError(\"Output datasets can't have a target_folder set.\")\n        use_mounting = True if self.use_mounting is None else self.use_mounting\n        if use_mounting:\n            status += \"uploaded while the job runs.\"\n            result = dataset.as_mount()\n        else:\n            status += \"uploaded when the job completes.\"\n            result = dataset.as_upload()\n        logging.info(status)\n        return result\n\n\nStrOrDatasetConfig = Union[str, DatasetConfig]\n\n\ndef _replace_string_datasets(datasets: List[StrOrDatasetConfig],\n                             default_datastore_name: str) -> List[DatasetConfig]:\n    \"\"\"\n    Processes a list of input or output datasets. All entries in the list that are strings are turned into\n    DatasetConfig objects, using the string as the dataset name, and pointing to the default datastore.\n    :param datasets: A list of datasets, each given either as a string or a DatasetConfig object.\n    :param default_datastore_name: The datastore to use for all datasets that are only specified via their name.\n    :return: A list of DatasetConfig objects, in the same order as the input list.\n    \"\"\"\n    return [DatasetConfig(name=d, datastore=default_datastore_name) if isinstance(d, str) else d\n            for d in datasets]\n", "path": "src/health/azure/datasets.py"}]}