diff --git a/mlrun/__init__.py b/mlrun/__init__.py index 63c360d357c..7f47c46a9f8 100644 --- a/mlrun/__init__.py +++ b/mlrun/__init__.py @@ -26,6 +26,7 @@ "VolumeMount", ] +import collections from os import environ, path from typing import Optional @@ -238,7 +239,7 @@ def order_env_vars(env_vars: dict[str, str]) -> dict[str, str]: """ ordered_keys = mlconf.get_ordered_keys() - ordered_env_vars: dict[str, str] = {} + ordered_env_vars = collections.OrderedDict() # First, add the ordered keys to the dictionary for key in ordered_keys: diff --git a/tests/test_config.py b/tests/test_config.py index a01e97e7225..2e3ae4ffbfe 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import collections import os import pathlib import subprocess @@ -587,12 +588,15 @@ def test_set_environment_cred(): def test_env_from_file(): env_path = str(assets_path / "envfile") env_dict = mlrun.set_env_from_file(env_path, return_dict=True) - assert env_dict == { - "ENV_ARG1": "123", - "ENV_ARG2": "abc", - "MLRUN_HTTPDB__HTTP__VERIFY": "false", - "MLRUN_KFP_TTL": "12345", - } + + assert env_dict == collections.OrderedDict( + { + "MLRUN_HTTPDB__HTTP__VERIFY": "false", + "MLRUN_KFP_TTL": "12345", + "ENV_ARG1": "123", + "ENV_ARG2": "abc", + } + ) assert mlrun.mlconf.kfp_ttl == 12345 for key, value in env_dict.items(): assert os.environ[key] == value