intel / certified-developer

Official repository of the Intel Certified Developer Program
https://www.intel.com/content/www/us/en/developer/certification/mlops.html?
31 stars 28 forks source link

Resolve Pydantic Model Namespace Conflict Warnings #15

Open ZioGuillo opened 5 months ago

ZioGuillo commented 5 months ago

Summary:

This PR addresses persistent UserWarnings related to field names in Pydantic models that were previously thought to conflict with protected namespaces within Pydantic's internal mechanics. Despite attempts to rename fields to avoid these conflicts, warnings continued to be raised, suggesting fields like model_identifier and model_storagepath conflicted with a protected namespace "model".

Issue Description:

Warnings were encountered as follows:

UserWarning: Field "model_identifier" has conflict with protected namespace "model_". 
UserWarning: Field "model_storage_path" has conflict with protected namespace "model_".

These warnings suggested a conflict with Pydantic's internal namespace, misleadingly pointing towards the resolution to set model_config['protected_namespaces'] = (), which is not supported by Pydantic's public API or documentation.

Resolution: Upon further investigation and discussion, I was determined that the direct advice provided by the warnings was not applicable, as Pydantic does not officially support a model_config['protected_namespaces'] configuration. Therefore, the approach to resolve these warnings involved:

Testing:

After the changes in the Model and the train code I run the test in the lab running:

curl -i POST http://localhost:5000/train -H "Content-Type: application/json" -d '{"file":"sensor_data.pkl", "identifier":"model", "storage_path":"./", "test_size":25, "ncpu":4, "mlflow_tracking_uri":"./mlruns", "mlflow_experiment":"apples01"}'

having success results :

Screenshot 2024-02-03 at 4 39 24 PM

and verifying in the MLFlow UI:

Screenshot 2024-02-03 at 4 42 38 PM

For the lab4 after the changes:

Screenshot 2024-02-04 at 11 26 55 AM

For the lab7 after the changes:

Screenshot 2024-02-04 at 9 00 55 PM