Skip to content

pin s3 worker count for kubernetes tasks #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions metaflow/plugins/airflow/airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ def _to_job(self, node):
"METAFLOW_DATATOOLS_S3ROOT": DATATOOLS_S3ROOT,
"METAFLOW_DEFAULT_DATASTORE": self.flow_datastore.TYPE,
"METAFLOW_DEFAULT_METADATA": "service",
"METAFLOW_S3_WORKER_COUNT": max(
1, int(float(k8s_deco.attributes["cpu"])) - 2
),
"METAFLOW_KUBERNETES_WORKLOAD": str(
1
), # This is used by kubernetes decorator.
Expand Down
3 changes: 3 additions & 0 deletions metaflow/plugins/argo/argo_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,9 @@ def _container_templates(self):
"METAFLOW_DATATOOLS_S3ROOT": DATATOOLS_S3ROOT,
"METAFLOW_DEFAULT_DATASTORE": self.flow_datastore.TYPE,
"METAFLOW_DEFAULT_METADATA": DEFAULT_METADATA,
"METAFLOW_S3_WORKER_COUNT": max(
1, int(float(resources["cpu"])) - 2
),
"METAFLOW_CARD_S3ROOT": CARD_S3ROOT,
"METAFLOW_KUBERNETES_WORKLOAD": 1,
"METAFLOW_KUBERNETES_FETCH_EC2_METADATA": KUBERNETES_FETCH_EC2_METADATA,
Expand Down
1 change: 1 addition & 0 deletions metaflow/plugins/aws/batch/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def create_job(
.environment_variable("METAFLOW_DEFAULT_DATASTORE", "s3")
.environment_variable("METAFLOW_DEFAULT_METADATA", DEFAULT_METADATA)
.environment_variable("METAFLOW_CARD_S3ROOT", CARD_S3ROOT)
.environment_variable("METAFLOW_S3_WORKER_COUNT", max(1, int(cpu) - 2))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would we need a change in step functions as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

step-functions calls the batch implementation so this should apply there as well. will verify

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed, step-functions is setting the env correctly through the changes in Batch

.environment_variable("METAFLOW_OTEL_ENDPOINT", OTEL_ENDPOINT)
.environment_variable("METAFLOW_RUNTIME_ENVIRONMENT", "aws-batch")
)
Expand Down
12 changes: 9 additions & 3 deletions metaflow/plugins/kubernetes/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
ARGO_EVENTS_INTERNAL_WEBHOOK_URL,
ARGO_EVENTS_SERVICE_ACCOUNT,
ARGO_EVENTS_WEBHOOK_AUTH,
ARGO_WORKFLOWS_KUBERNETES_SECRETS,
ARGO_WORKFLOWS_ENV_VARS_TO_SKIP,
ARGO_WORKFLOWS_KUBERNETES_SECRETS,
AWS_SECRETS_MANAGER_DEFAULT_REGION,
AZURE_KEY_VAULT_PREFIX,
AZURE_STORAGE_BLOB_SERVICE_ENDPOINT,
Expand All @@ -33,14 +33,13 @@
GCP_SECRET_MANAGER_PREFIX,
KUBERNETES_FETCH_EC2_METADATA,
KUBERNETES_SANDBOX_INIT_SCRIPT,
KUBERNETES_SECRETS,
OTEL_ENDPOINT,
S3_ENDPOINT_URL,
S3_SERVER_SIDE_ENCRYPTION,
SERVICE_HEADERS,
KUBERNETES_SECRETS,
SERVICE_INTERNAL_URL,
)
from metaflow.unbounded_foreach import UBF_CONTROL, UBF_TASK
from metaflow.metaflow_config_funcs import config_values
from metaflow.mflog import (
BASH_SAVE_LOGS,
Expand All @@ -49,6 +48,7 @@
get_log_tailer,
tail_logs,
)
from metaflow.unbounded_foreach import UBF_CONTROL, UBF_TASK

from .kubernetes_client import KubernetesClient

Expand Down Expand Up @@ -293,6 +293,9 @@ def create_jobset(
"METAFLOW_ARGO_WORKFLOWS_ENV_VARS_TO_SKIP",
ARGO_WORKFLOWS_ENV_VARS_TO_SKIP,
)
.environment_variable(
"METAFLOW_S3_WORKER_COUNT", max(1, int(float(cpu)) - 2)
)
.environment_variable("METAFLOW_OTEL_ENDPOINT", OTEL_ENDPOINT)
# Skip setting METAFLOW_DATASTORE_SYSROOT_LOCAL because metadata sync
# between the local user instance and the remote Kubernetes pod
Expand Down Expand Up @@ -596,6 +599,9 @@ def create_job_object(
"METAFLOW_ARGO_WORKFLOWS_ENV_VARS_TO_SKIP",
ARGO_WORKFLOWS_ENV_VARS_TO_SKIP,
)
.environment_variable(
"METAFLOW_S3_WORKER_COUNT", max(1, int(float(cpu)) - 2)
)
.environment_variable("METAFLOW_OTEL_ENDPOINT", OTEL_ENDPOINT)
# Skip setting METAFLOW_DATASTORE_SYSROOT_LOCAL because metadata sync
# between the local user instance and the remote Kubernetes pod
Expand Down
Loading