[Batch] az batch task file download Fixed AttributeError when downloading batch task files#33253
[Batch] az batch task file download Fixed AttributeError when downloading batch task files#33253
az batch task file download Fixed AttributeError when downloading batch task files#33253Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Hi @johanyim, |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution @johanyim! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
Fixes az batch task file download failing with an AttributeError when the destination is a directory by using the correct namespace attribute for deriving the output filename.
Changes:
- Update
validate_file_destinationto usenamespace.file_path(instead ofnamespace.file_name) when computing the downloaded filename.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| file_dir = os.path.dirname(path) | ||
| if os.path.isdir(path): | ||
| file_name = os.path.basename(namespace.file_name) | ||
| file_name = os.path.basename(namespace.file_path) |
There was a problem hiding this comment.
This validator now reads namespace.file_path, but the existing unit test test_batch_validate_file_destination still sets ns.file_name (see batch/tests/latest/test_batch_commands.py). CI will likely fail unless the test (and any other callers constructing a namespace for this validator) is updated to use file_path instead of file_name.
| file_name = os.path.basename(namespace.file_path) | |
| source_path = getattr(namespace, 'file_path', None) or getattr(namespace, 'file_name', None) | |
| if not source_path: | |
| raise ValueError("Missing file path for destination filename resolution.") | |
| file_name = os.path.basename(source_path) |
Related command
az batch task file download
Description
This PR fixes a bug when downloading a file from the working directory (wd/) of a batch task. The command
az batch task file download \ --job-id "job-1" \ --task-id "task-1" \ --file-path "wd/path/to/file.txt" \ --destination "local/machine/output/"will throw an error such as:
This PR fixes that incorrect attribute name such that the command will work as intended.
Testing Guide
Consider a batch job (
job-1) with a task (task-1). Create a directory on the local machine in your working directory, (./output/) and run the following to extract thestdout.txtfile from the task, assuming it exists.az batch task file download \ --job-id "job-1" \ --task-id "task-1" \ --file-path "wd/stdout.txt" \ --destination "./output/"History Notes
[az batch file task download]: FIX: validate_file_destination incorrect attribute name
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.