1
resposta

Erro ao rodar Mlflow models predict no windows 11

Boa tarde,

Ja rodei o codigo de n formas e nao consegui avancar esse erro, ja rodei com caminho absoluto sem ser absoluto e apresenta mesmo erro.

Sem caminho absoluto do modelo. mlflow models predict -m 'runs:/40f7b4b7d1924344bd662e6e55c0a80a/model' -i 'C:\Users\user\mlflow\data\processed\casas_X.csv' -t 'csv' -o 'precos2.csv'

Com caminho absoluto PS C:\Users\user\mlflow> mlflow models predict -m 'C:\Users\user\mlflow\src\models\predict_model.py' -i 'C:\Users\user\mlflow\data\processed\casas_X.csv' -t 'csv' -o 'precos2.csv' Downloading artifacts: 100%|███████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<?, ?it/s] Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in run_code File "C:\Users\user\anaconda3\Scripts\mlflow.exe_main.py", line 7, in File "C:\Users\user\anaconda3\Lib\site-packages\click\core.py", line 1157, in call return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\mlflow\models\cli.py", line 141, in predict return python_api.predict(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\mlflow\models\python_api.py", line 232, in predict predict(input_path) File "C:\Users\user\anaconda3\Lib\site-packages\mlflow\models\python_api.py", line 204, in predict return get_flavor_backend( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\mlflow\models\flavor_backend_registry.py", line 46, in get_flavor_backend model = Model.load(local_path) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\mlflow\models\model.py", line 657, in load return cls.from_dict(yaml.safe_load(f.read())) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\yaml_init.py", line 125, in safe_load return load(stream, SafeLoader) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\yaml_init.py", line 81, in load return loader.get_single_data() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\yaml\constructor.py", line 49, in get_single_data node = self.get_single_node() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\yaml\composer.py", line 39, in get_single_node if not self.check_event(StreamEndEvent): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\yaml\parser.py", line 98, in check_event self.current_event = self.state() ^^^^^^^^^^^^ File "C:\Users\user\anaconda3\Lib\site-packages\yaml\parser.py", line 171, in parse_document_start raise ParserError(None, None, yaml.parser.ParserError: expected '', but found '' in "", line 5, column 1: loaded_model = mlflow.pyfunc.loa ...

1 resposta

Oi, William

No comando mlflow models predict, tenha certeza de que o caminho do modelo especificado (usando -m) corresponde exatamente ao local onde ele foi registrado. No seu caso, ao usar runs:/40f7b4b7d1924344bd662e6e55c0a80a/model, o MLflow tentará buscar o modelo a partir de um experimento. Se você tiver baixado o modelo para uso local, o caminho absoluto será mais seguro.

veja se o MLflow foi instalado corretamente e se você tem permissões de leitura/escrita nas pastas usadas. Execute o prompt como administrador para garantir que não haja restrições.

No Windows, às vezes as aspas simples ' podem gerar problemas. Experimente trocar por aspas duplas " no comando para garantir compatibilidade.

O erro também pode vir de incompatibilidades nas dependências do MLflow instaladas no Conda. Experimente atualizar o MLflow e suas dependências:

pip install --upgrade mlflow

Caso continue com o problema, pode ser uma boa tentar rodar o código em um ambiente virtual específico para evitar conflitos.