From 0d2766c2d05049b833febe0b3063cbcc1e4baff7 Mon Sep 17 00:00:00 2001 From: luiz Date: Sun, 12 Nov 2023 14:47:16 +0100 Subject: [PATCH] better hot reload for local pieces --- .../custom_operators/docker_operator.py | 20 ++++++++++++------- src/domino/task.py | 10 +++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/domino/custom_operators/docker_operator.py b/src/domino/custom_operators/docker_operator.py index 6ac4c9b7..62bd6600 100644 --- a/src/domino/custom_operators/docker_operator.py +++ b/src/domino/custom_operators/docker_operator.py @@ -52,13 +52,19 @@ def __init__( shared_storage_container_path = '/home/shared_storage' mounts = [] - # TODO remove - used in DEV only - mounts = [ - # TODO remove - # Mount(source='/home/vinicius/Documents/work/tauffer/domino/src/domino', target='/usr/local/lib/python3.10/site-packages/domino/', type='bind', read_only=True), - # Mount(source='/mnt/shared_storage/Github/domino', target='/usr/local/lib/python3.10/site-packages/domino/', type='bind', read_only=True), - # Mount(source='/mnt/shared_storage/Github/default_domino_pieces', target='/home/domino/pieces_repository/', type='bind', read_only=True), - ] + # TODO remove - used in DEV only ####################### + dev_pieces = False + if dev_pieces: + piece_repo_name = repository_url.split("/")[-1] + local_repos_path = f"/mnt/shared_storage/Github/{piece_repo_name}" + mounts = [ + # TODO remove + # Mount(source='/home/vinicius/Documents/work/tauffer/domino/src/domino', target='/usr/local/lib/python3.10/site-packages/domino/', type='bind', read_only=True), + Mount(source='/mnt/shared_storage/Github/domino', target='/usr/local/lib/python3.10/site-packages/domino/', type='bind', read_only=True), + Mount(source=local_repos_path, target='/home/domino/pieces_repository/', type='bind', read_only=True), + ] + ######################################################## + if self.workflow_shared_storage and str(self.workflow_shared_storage.source.value).lower() == str(getattr(StorageSource, 'local').value).lower(): mounts.append( Mount( diff --git a/src/domino/task.py b/src/domino/task.py index 4b96a2e7..15d51372 100644 --- a/src/domino/task.py +++ b/src/domino/task.py @@ -15,7 +15,7 @@ class Task(object): """ - The Task object represents a task in a workflow. + The Task object represents a task in a workflow. It is only instantiated by processes parsing dag files in Airflow. """ def __init__( @@ -52,9 +52,9 @@ def __init__( provider_options = workflow_shared_storage.pop("provider_options", {}) if shared_storage_map[shared_storage_source_name]: self.workflow_shared_storage = shared_storage_map[shared_storage_source_name]( - **workflow_shared_storage, + **workflow_shared_storage, **provider_options - ) + ) else: self.workflow_shared_storage = shared_storage_map[shared_storage_source_name] @@ -62,7 +62,7 @@ def __init__( self.container_resources = container_resources # Get deploy mode - self.deploy_mode = os.environ.get('DOMINO_DEPLOY_MODE') + self.deploy_mode = os.environ.get('DOMINO_DEPLOY_MODE') # Set up task operator self._task_operator = self._set_operator() @@ -97,7 +97,7 @@ def _set_operator(self) -> BaseOperator: ) ) - elif self.deploy_mode in ["local-k8s", "local-k8s-dev", "prod"]: + elif self.deploy_mode in ["local-k8s", "local-k8s-dev", "prod"]: # References: # - https://airflow.apache.org/docs/apache-airflow/1.10.14/_api/airflow/contrib/operators/kubernetes_pod_operator/index.html # - https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html