Skip to content
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

feat: allow for force reinstall dependencies on cluster when set up #32

Merged
merged 1 commit into from
Oct 2, 2024
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
30 changes: 30 additions & 0 deletions src/ot_orchestration/utils/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
GCP_REGION,
GCP_ZONE,
)
from ot_orchestration.utils.path import GCSPath


def create_cluster(
Expand Down Expand Up @@ -273,3 +274,32 @@ def generate_dag(cluster_name: str, tasks: list[DataprocSubmitJobOperator]) -> A
task.set_downstream(delete_cluster_task)

return tasks


def reinstall_dependencies(
cluster_name: str, cluster_init_script: str
) -> DataprocSubmitJobOperator:
"""Force install dependencies on a Dataproc cluster.

Args:
cluster_name (str): Name of the cluster.
cluster_init_script (str): Name of the script to run in the cluster to update the dependencies.

Returns:
DataprocSubmitJobOperator: Airflow task to install dependencies on a Dataproc cluster.
"""
cluster_init_script_name = GCSPath(cluster_init_script).segments["filename"]
return submit_job(
cluster_name=cluster_name,
task_id="install_dependencies",
job_type="pig_job",
job_specification={
"jar_file_uris": [cluster_init_script],
"query_list": {
"queries": [
f"sh chmod 750 $PWD/{cluster_init_script_name}",
f"sh $PWD/{cluster_init_script_name}",
]
},
},
)