Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/omotes_sdk/prefect_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@


def _build_minio_result_storage(
minio_host: str,
minio_port: str | int,
minio_url: str,
access_key: str,
secret_key: str,
bucket: str = "prefect-results",
Expand All @@ -52,14 +51,12 @@ def _build_minio_result_storage(
RemoteFileSystem: Configured Prefect result storage block.

"""
endpoint_url = f"http://{minio_host}:{minio_port}"

return RemoteFileSystem(
basepath=f"s3://{bucket}/{prefix}",
settings={
"key": access_key,
"secret": secret_key,
"client_kwargs": {"endpoint_url": endpoint_url},
"client_kwargs": {"endpoint_url": minio_url},
},
)

Expand Down Expand Up @@ -210,12 +207,12 @@ def write_flow_return_artifact_to_minio(
minio_port: str,
access_key: str,
secret_key: str,
minio_host_external: str,
minio_external_url: str,
) -> str | None:
"""Persist flow return fields to MinIO and publish Prefect links to those objects.

``minio_host`` is used for storage operations from the worker, while
``minio_host_external`` is used to generate browser-accessible URLs.
``minio_external_url`` is the complete URL used to generate browser-accessible URLs.

Returns:
str | None: Run folder path in MinIO, or None if not in flow context.
Expand All @@ -224,8 +221,8 @@ def write_flow_return_artifact_to_minio(
if not in_prefect_flow_context():
return None

minio_block = _build_minio_result_storage(minio_host, minio_port, access_key, secret_key)
external_minio_block = _build_minio_result_storage(minio_host_external, minio_port, access_key, secret_key)
minio_block = _build_minio_result_storage(f"http://{minio_host}:{minio_port}", access_key, secret_key)
external_minio_block = _build_minio_result_storage(minio_external_url, access_key, secret_key)
run_folder_path = _sanitize_for_minio(f"{flow_run.get_name()}-{_get_flow_run_id_first_part()}")

for field_name, field_value in flow_result:
Expand Down Expand Up @@ -639,7 +636,7 @@ async def _resolve_artifact_data(
return data

url = url_match.group("url")
minio_block = _build_minio_result_storage(minio_host, minio_port, access_key, secret_key)
minio_block = _build_minio_result_storage(f"http://{minio_host}:{minio_port}", access_key, secret_key)
storage_url = urlsplit(minio_block.basepath)
storage_path = "/".join(part for part in (storage_url.netloc, storage_url.path.strip("/")) if part)
object_path = urlsplit(url).path.removeprefix(f"/{storage_path}/")
Expand Down
Loading