Azure / Azure/azure-cli-extensions
az ml component create : Error with code: No value for given attribute
- Dominant language
- Python
- Stars
- 454
- Forks
- 1.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 64
Description
Hello,
I would like to create a custom component in AzureML.
This component is very basic. It generates a json file just by iterating over files in a storage.
I have only one input and i write the file in the same place than the input.
### Related command
az ml component create --file create_metadata_jsonl_component.yaml -w $AZUREML_WORKSPACE_NAME --verbose
### Extension name (the extension in question)
The problem is with azureml extension.
azure-cli 2.47.0
core 2.47.0
telemetry 1.0.8
Extensions:
ml 2.15.1
Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0
### Description of issue (in as much detail as possible)
When i run my command, i have an error :
```bash
az ml component create --file create_metadata_jsonl_component.yaml -w $AZUREML_WORKSPACE_NAME --verbose
Error with code: No value for given attribute
Command ran in 1.127 seconds (init: 0.160, invoke: 0.966)
```
Here are my files :
```yaml
# create_metadata_jsonl_component.yaml
$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json
type: command
name: create_metadata_jsonl
display_name: Create Metadata JsonL
version: 1
is_deterministic: false
code: ./
command: >-
python create_metadata_jsonl.py
--input_dir ${{inputs.input_dir}}
inputs:
input_dir:
type: uri_folder
mode: rw_mount
environment:
conda_file: ./conda.yaml
image: mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04
```
-----
```python
# create_metadata_jsonl.py
import argparse
import os
from tqdm import tqdm
import logging
import json
from pathlib import Path
from mldesigner import command_component, Input, Output
EXTENSIONS= ['.jpg','.png','.jpeg','.bmp']
FILENAME = "metadata.jsonl"
parser = argparse.ArgumentParser()
parser.add_argument('--input_dir',type=str,help="Directory containing images")
def create_metadata_jsonl(input_dir:str):
metadatas=[]
for filename in tqdm(os.listdir(input_dir)):
filepath = os.path.join(input_dir,filename)
extension = os.path.splitext(filepath)[1]
if not extension in EXTENSIONS:
logging.info(f'{filepath} ignored because {extension} not in {EXTENSIONS}')
continue
if not os.path.isfile(filepath):
logging.info(f'{filepath} ignored because it is not a file')
file_caption = os.path.splitext(filename)[0]
file_dict = {"file_name":filename,"text":file_caption}
metadatas.append(file_dict)
with open(os.path.join(input_dir,'metadata.jsonl'),'w') as jsf:
for meta in metadatas:
jsf.write(json.dumps(meta)+'\n')
if __name__=="__main__":
args = parser.parse_args()
create_metadata_jsonl(args.input_dir)
```
It seems very basic to me and i don't understand the issue.
Maybe the error code is not enough explicit.
It says that there is an issue with **code:** but ***code*** is present in my yaml file and i execute the code from the directory containing files.
If you have any idea of what went wrong.
thanks,
regards,
Contributor guide
Assessment
This issue has not been assessed yet.