This repository was archived by the owner on Jul 1, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Decorator configuration improvements #67
Closed
Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3767ade
changes
fef3233
update
9235c3d
minor fix
8bebbba
example dag updated
bb5b117
update
f60c185
Updated code
a8629e6
minor change
cbf93ee
Merge branch 'main' into decorator_bug_fix
tatiana df95ef1
Release 0.3.0a1
tatiana 4f91d26
Fix issue in the decorator
tatiana 0491d7e
Release 0.3.0a2
tatiana cb98a6c
Fix another issue after joining the two changes
tatiana 866756d
Release 0.3.0a3
tatiana 682b5d4
Fix issue when running
tatiana 2a37b13
Release 0.3.0a4
tatiana 8fab03d
Release 0.3.0a5
tatiana fc47b75
Give visibility of error while trying to run operator in Astro
tatiana 8cc17b3
Release 0.3.0a6
tatiana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
|
|
||
| from airflow.decorators import dag, task | ||
|
|
||
| from ray_provider.decorators.ray import ray | ||
|
|
||
|
|
||
| def generate_config(): | ||
| CONN_ID = "ray_conn" | ||
| RAY_SPEC = Path(__file__).parent / "scripts/ray.yaml" | ||
| FOLDER_PATH = Path(__file__).parent / "ray_scripts" | ||
| return { | ||
| "conn_id": CONN_ID, | ||
| "runtime_env": {"working_dir": str(FOLDER_PATH), "pip": ["numpy"]}, | ||
| "num_cpus": 1, | ||
| "num_gpus": 0, | ||
| "memory": 0, | ||
| "poll_interval": 5, | ||
| "ray_cluster_yaml": str(RAY_SPEC), | ||
| "xcom_task_key": "dashboard", | ||
| } | ||
|
|
||
|
|
||
| @dag( | ||
| dag_id="Ray_Taskflow_Example_Dynamic_Config", | ||
| start_date=datetime(2023, 1, 1), | ||
| schedule=None, | ||
| catchup=False, | ||
| tags=["ray", "example"], | ||
| ) | ||
| def ray_taskflow_dag(): | ||
|
|
||
| @task | ||
| def generate_data(): | ||
| return [1, 2, 3] | ||
|
|
||
| @ray.task(config=generate_config) | ||
|
venkatajagannath marked this conversation as resolved.
Outdated
|
||
| def process_data_with_ray(data): | ||
| import numpy as np | ||
| import ray | ||
|
|
||
| @ray.remote | ||
| def square(x): | ||
| return x**2 | ||
|
|
||
| ray.init() | ||
| data = np.array(data) | ||
| futures = [square.remote(x) for x in data] | ||
| results = ray.get(futures) | ||
| mean = np.mean(results) | ||
| print(f"Mean of this population is {mean}") | ||
| return mean | ||
|
|
||
| data = generate_data() | ||
| process_data_with_ray(data) | ||
|
|
||
|
|
||
| ray_example_dag = ray_taskflow_dag() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.