%20aufgetreten.png)
Ich habe einen mlflow
Server, der auf gehostet wird aws
und im Hintergrund zur Speicherung verwendet wird s3
. Ich versuche, ein auszuführen, lambda-function
das ein Python-Skript ausführt, das auf den mlflow
Server zugreift, ein pytorch
Modell lädt, Vorhersagen trifft und fertig ist. Der Code, bei dem meine Probleme auftreten, ist:
with open('./data/api_keys.json', 'r') as f:
API_KEYS = json.load(f)
os.environ['AWS_DEFAULT_REGION'] = API_KEYS['AWS_DEFAULT_REGION']
os.environ["AWS_ACCESS_KEY_ID"] = API_KEYS['AWS_ACCESS_KEY_ID']
os.environ["AWS_SECRET_ACCESS_KEY"] = API_KEYS['AWS_SECRET_ACCESS_KEY']
mlflow.set_tracking_uri(MLFLOW_TRACKING_URI)
model = mlflow.pytorch.load_model(MODEL_URI) # <---- error thrown here
Der Traceback von cloudwatch
lautet:
File "/app/production_script.py", line 26, in <module>
model = mlflow.pytorch.load_model(MODEL_URI)
File "/usr/local/lib/python3.9/site-packages/mlflow/pytorch/__init__.py", line 693, in load_model
local_model_path = _download_artifact_from_uri(artifact_uri=model_uri)
File "/usr/local/lib/python3.9/site-packages/mlflow/tracking/artifact_utils.py", line 95, in _download_artifact_from_uri
return get_artifact_repository(artifact_uri=root_uri).download_artifacts(
File "/usr/local/lib/python3.9/site-packages/mlflow/store/artifact/artifact_repo.py", line 179, in download_artifacts
if self._is_directory(artifact_path):
File "/usr/local/lib/python3.9/site-packages/mlflow/store/artifact/artifact_repo.py", line 61, in _is_directory
listing = self.list_artifacts(artifact_path)
File "/usr/local/lib/python3.9/site-packages/mlflow/store/artifact/s3_artifact_repo.py", line 121, in list_artifacts
for result in results:
File "/usr/local/lib/python3.9/site-packages/botocore/paginate.py", line 269, in __iter__
response = self._make_request(current_kwargs)
File "/usr/local/lib/python3.9/site-packages/botocore/paginate.py", line 357, in _make_request
return self._method(**current_kwargs)
File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 530, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 960, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidToken) when calling the ListObjectsV2 operation: The provided token is malformed or otherwise invalid.
Gemäß derDokumente,ListObjectsV2
Gibt mit jeder Anforderung einige oder alle (bis zu 1.000) der Objekte in einem Bucket zurück.
Um diesen Vorgang zu verwenden, müssen Sie Lesezugriff auf den Bucket haben.
Um diese Aktion in einer AWS Identity and Access Management (IAM)-Richtlinie zu verwenden, müssen Sie über die Berechtigung zum Ausführen der Aktion s3:ListBucket verfügen.
In meinem policy
dafür definierten lambda-function
habe ich s3:ListBucket
die Berechtigung für den Bucket, der mlflow
auf gehostet wird.
Alle Ideen zur Behebung dieses Problems sind willkommen.