Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.58k stars 2.8k forks source link

MLTable save results in incorrect MLTable file with datetime formats #33067

Open martheveldhuis opened 11 months ago

martheveldhuis commented 11 months ago

Describe the bug Saving an mltable after applying the convert_column_types function with a datetime column including formats, results in an incorrect MLTable file.

To Reproduce Steps to reproduce the behavior:

  1. Assign formatting to datetime column

column_types = {"datetime_call": DataType.to_datetime(formats="%d-%m-%y %H:%M:%S%z")}

  1. Convert column types

tbl = tbl.convert_column_types(column_types=column_types)

  1. Save MLTable

tbl.save(<path>)

  1. The resulting MLTable file has the step of converting of column types formatted like this:
  - column_type:
      datetime:
        formats: '%d-%m-%y %H:%M:%S%z'
    columns: datetime_call

Expected behavior

The MLTable should be formated like this:

  - column_type:
      datetime:
        formats: 
        - '%d-%m-%y %H:%M:%S%z'
    columns: datetime_call

Screenshots

Additional context

Creating an asset from this current MLTable file will produce an error:

ml_client.data.create_or_update(tbl)
  File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/azure/ai/ml/_telemetry/activity.py", line 275, in wrapper
    return f(*args, **kwargs)
  File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/azure/ai/ml/operations/_data_operations.py", line 408, in create_or_update
    log_and_raise_error(ex)
  File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/azure/ai/ml/_exception_helper.py", line 337, in log_and_raise_error
    raise Exception(formatted_error)
Exception: 

1) One or more fields are invalid

Details: 

(x) datetime.formats: '%d-%m-%y %H:%M:%S%z' is not of type 'array'
Invalid MLTable metadata schema:
{
  "type": "array",
  "items": {
    "type": "string"
  }
}

Resolutions: 
1) Double-check that all specified parameters are of the correct types and formats prescribed by the Data schema.
If using the CLI, you can also check the full log in debug mode for more details by adding --debug to the end of your command
kristapratico commented 11 months ago

@martheveldhuis thanks for your issue, @azureml-github will take a look and respond as soon as possible.

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @azureml-github @Azure/azure-ml-sdk @klaaslanghout.

JB9891 commented 10 months ago

Any updates on this topic ?

martheveldhuis commented 9 months ago

Just wanted to bump this; it is still broken in version 1.6.0