|
| 1 | +--- |
| 2 | +title: Debug and troubleshoot ParallelRunStep |
| 3 | +titleSuffix: Azure Machine Learning |
| 4 | +description: Debug and troubleshoot ParallelRunStep in machine learning pipelines in the Azure Machine Learning SDK for Python. Learn common pitfalls for developing with pipelines, and tips to help you debug your scripts before and during remote execution. |
| 5 | +services: machine-learning |
| 6 | +ms.service: machine-learning |
| 7 | +ms.subservice: core |
| 8 | +ms.topic: conceptual |
| 9 | +ms.reviewer: trbye, jmartens, larryfr, vaidyas |
| 10 | +ms.author: trmccorm |
| 11 | +author: tmccrmck |
| 12 | +ms.date: 01/15/2020 |
| 13 | +--- |
| 14 | + |
| 15 | +# Debug and troubleshoot ParallelRunStep |
| 16 | +[!INCLUDE [applies-to-skus](../../includes/aml-applies-to-basic-enterprise-sku.md)] |
| 17 | + |
| 18 | +In this article, you learn how to debug and troubleshoot the [ParallelRunStep](https://docs.microsoft.com/python/api/azureml-contrib-pipeline-steps/azureml.contrib.pipeline.steps.parallel_run_step.parallelrunstep?view=azure-ml-py) class from the [Azure Machine Learning SDK](https://docs.microsoft.com/python/api/overview/azure/ml/intro?view=azure-ml-py). |
| 19 | + |
| 20 | +## Testing scripts locally |
| 21 | + |
| 22 | +See the [Testing scripts locally section](how-to-debug-pipelines.md#testing-scripts-locally) for machine learning pipelines. Your ParallelRunStep runs as a step in ML pipelines so the same answer applies to both. |
| 23 | + |
| 24 | +## Debugging scripts from remote context |
| 25 | + |
| 26 | +The transition from debugging a scoring script locally to debugging a scoring script in an actual pipeline can be a difficult leap. For information on finding your logs in the portal, the [machine learning pipelines section on debugging scripts from a remote context](how-to-debug-pipelines.md#debugging-scripts-from-remote-context). The information in that section also applies to a parallel step run. |
| 27 | + |
| 28 | +For example, the log file `70_driver_log.txt` contains information from the controller that launches parallel run step code. |
| 29 | + |
| 30 | +Because of the distributed nature of parallel run jobs, there are logs from several different sources. However, two consolidated files are created that provide high-level information: |
| 31 | + |
| 32 | +- `~/logs/overview.txt`: This file provides a high-level info about the number of mini-batches (also known as tasks) created so far and number of mini-batches processed so far. At this end, it shows the result of the job. If the job failed, it will show the error message and where to start the troubleshooting. |
| 33 | + |
| 34 | +- `~/logs/sys/master.txt`: This file provides the master node (also known as the orchestrator) view of the running job. Includes task creation, progress monitoring, the run result. |
| 35 | + |
| 36 | +Logs generated from entry script using EntryScript.logger and print statements will be found in following files: |
| 37 | + |
| 38 | +- `~/logs/user/<ip_address>/Process-*.txt`: This file contains logs written from entry_script using EntryScript.logger. It also contains print statement (stdout) from entry_script. |
| 39 | + |
| 40 | +When you need a full understanding of how each node executed the score script, look at the individual process logs for each node. The process logs can be found in the `sys/worker` folder, grouped by worker nodes: |
| 41 | + |
| 42 | +- `~/logs/sys/worker/<ip_address>/Process-*.txt`: This file provides detailed info about each mini-batch as it is picked up or completed by a worker. For each mini-batch, this file includes: |
| 43 | + |
| 44 | + - The IP address and the PID of the worker process. |
| 45 | + - The total number of items, successfully processed items count, and failed item count. |
| 46 | + - The start time, duration, process time and run method time. |
| 47 | + |
| 48 | +You can also find information on the resource usage of the processes for each worker. This information is in CSV format and is located at `~/logs/sys/perf/<ip_address>/`. For a single node, job files will be available under `~logs/sys/perf`. For example, when checking for resource utilization, look at the following files: |
| 49 | + |
| 50 | +- `Process-*.csv`: Per worker process resource usage. |
| 51 | +- `sys.csv`: Per node log. |
| 52 | + |
| 53 | +### How do I log from my user script from a remote context? |
| 54 | +You can get a logger from EntryScript as shown in below sample code to make the logs show up in **logs/user** folder in the portal. |
| 55 | + |
| 56 | +**A sample entry script using the logger:** |
| 57 | +```python |
| 58 | +from entry_script import EntryScript |
| 59 | + |
| 60 | +def init(): |
| 61 | + """ Initialize the node.""" |
| 62 | + entry_script = EntryScript() |
| 63 | + logger = entry_script.logger |
| 64 | + logger.debug("This will show up in files under logs/user on the Azure portal.") |
| 65 | + |
| 66 | + |
| 67 | +def run(mini_batch): |
| 68 | + """ Accept and return the list back.""" |
| 69 | + # This class is in singleton pattern and will return same instance as the one in init() |
| 70 | + entry_script = EntryScript() |
| 71 | + logger = entry_script.logger |
| 72 | + logger.debug(f"{__file__}: {mini_batch}.") |
| 73 | + ... |
| 74 | + |
| 75 | + return mini_batch |
| 76 | +``` |
| 77 | + |
| 78 | +### How could I pass a side input such as, a file or file(s) containing a lookup table, to all my workers? |
| 79 | + |
| 80 | +Construct a [Dataset](https://docs.microsoft.com/python/api/azureml-core/azureml.core.dataset.dataset?view=azure-ml-py) object containing the side input and register with your workspace. After that you can access it in your inference script (for example, in your init() method) as follows: |
| 81 | + |
| 82 | +```python |
| 83 | +from azureml.core.run import Run |
| 84 | +from azureml.core.dataset import Dataset |
| 85 | + |
| 86 | +ws = Run.get_context().experiment.workspace |
| 87 | +lookup_ds = Dataset.get_by_name(ws, "<registered-name>") |
| 88 | +lookup_ds.download(target_path='.', overwrite=True) |
| 89 | +``` |
| 90 | + |
| 91 | +## Next steps |
| 92 | + |
| 93 | +* See the SDK reference for help with the [azureml-contrib-pipeline-step](https://docs.microsoft.com/python/api/azureml-contrib-pipeline-steps/azureml.contrib.pipeline.steps?view=azure-ml-py) package and the [documentation](https://docs.microsoft.com/python/api/azureml-contrib-pipeline-steps/azureml.contrib.pipeline.steps.parallelrunstep?view=azure-ml-py) for ParallelRunStep class. |
| 94 | + |
| 95 | +* Follow the [advanced tutorial](tutorial-pipeline-batch-scoring-classification.md) on using pipelines with parallel run step. |
0 commit comments