some-solstice-93243
08/28/2024, 5:39 PMancient-wolf-19325
08/28/2024, 5:39 PMflytekit.current_context().execution_id
method. Here's an example:
import flytekit
@flytekit.task
def my_task():
execution_id = flytekit.current_context().execution_id.name
print(f"Execution ID: {execution_id}")
This method retrieves the execution ID from the current Flyte context.
Would you like more detail?
Sources:
- Flyte GitHub Issue #3696 ๐ 0 button ๐ 0 button ๐ก Hint: Mention @runllm in the thread for followups.some-solstice-93243
08/28/2024, 5:45 PMancient-wolf-19325
08/28/2024, 5:45 PMimport os
bucket_name = os.getenv("FLYTE_STORAGE_BUCKET_NAME")
print(f"Bucket Name: {bucket_name}")
Would you like more detail?
Sources:
- Flyte Deployment Configuration
- Flyte Data Management ๐ 0 button ๐ 0 button ๐ก Hint: Mention @runllm in the thread for followups.some-solstice-93243
08/28/2024, 6:33 PMancient-wolf-19325
08/28/2024, 6:33 PMimport flytekit
@flytekit.task
def my_task():
storage_config = flytekit.current_context().storage
bucket_name = storage_config.default_remote.prefix
print(f"Bucket Name: {bucket_name}")
This method retrieves the storage configuration from the current Flyte context.
Would you like more detail?
Sources:
- Flyte Deployment Configuration
- Flyte Storage Configuration ๐ 0 button ๐ 0 button ๐ก Hint: Mention @runllm in the thread for followups.some-solstice-93243
08/28/2024, 7:36 PMAssertionError: STORAGE not available as a parameter in Flyte context - are you in right task-type?
ancient-wolf-19325
08/28/2024, 7:36 PMstorage:
type: s3
connection:
endpoint: http://minio.flyte.svc.cluster.local:9000
access-key: minio
secret-key: miniostorage
container: my-s3-bucket
2. Access Storage Configuration in Task:
Since Flyte does not expose storage configuration directly in the task context, you can pass the bucket name as an environment variable or task input. Here is an example of passing it as an environment variable:
import os
from flytekit import task, workflow
@task
def my_task() -> str:
bucket_name = os.getenv("FLYTE_STORAGE_BUCKET_NAME", "default-bucket")
print(f"Bucket Name: {bucket_name}")
return bucket_name
@workflow
def my_workflow() -> str:
return my_task()
if __name__ == "__main__":
os.environ["FLYTE_STORAGE_BUCKET_NAME"] = "my-s3-bucket"
print(my_workflow())
Would you like more detail?
Sources:
- https://github.com/flyteorg/flyte/issues/4503
- https://discuss.flyte.org/t/10142/hi-i-am-trying-to-return-a-spark-data-frame-but-having-this-/
Note: I wasnโt able to find highly relevant data sources, but above are a few potentially relevant links. ๐ 0 button ๐ 0 button ๐ก Hint: Mention @runllm in the thread for followups.some-solstice-93243
08/28/2024, 7:53 PMremote_path
of FlyteFile
for example?ancient-wolf-19325
08/28/2024, 7:53 PMstorage:
type: s3
connection:
endpoint: http://minio.flyte.svc.cluster.local:9000
access-key: minio
secret-key: miniostorage
container: my-dynamic-s3-bucket
2. Pass the Bucket Name to the Task:
You can pass the bucket name as an environment variable or as a task input. Hereโs an example using an environment variable:
import os
from flytekit import task, workflow, FlyteFile
@task
def my_task() -> str:
bucket_name = os.getenv("FLYTE_STORAGE_BUCKET_NAME", "default-bucket")
remote_path = f"s3://{bucket_name}/path/to/file"
flyte_file = FlyteFile(remote_path)
print(f"FlyteFile Path: {flyte_file.path}")
return flyte_file.path
@workflow
def my_workflow() -> str:
return my_task()
if __name__ == "__main__":
os.environ["FLYTE_STORAGE_BUCKET_NAME"] = "my-dynamic-s3-bucket"
print(my_workflow())
This approach allows you to dynamically reference the bucket name configured via the Helm chart by setting it as an environment variable.
Would you like more detail?
Sources:
- https://docs.flyte.org/en/latest/concepts/data_management.html
- https://github.com/flyteorg/flyte/issues/4881
Note: I wasnโt able to find highly relevant data sources, but above are a few potentially relevant links. ๐ 0 button ๐ 0 button ๐ก Hint: Mention @runllm in the thread for followups.