airflow-unicore-integration 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,4 +9,7 @@ def get_provider_info():
9
9
  "hook-class-name": "airflow_unicore_integration.hooks.unicore_hooks.UnicoreHook",
10
10
  }
11
11
  ],
12
+ "executors": [
13
+ "airflow_unicore_integration.executors.unicore_executor.UnicoreExecutor",
14
+ ],
12
15
  }
@@ -19,8 +19,8 @@ from airflow.executors.workloads import All
19
19
  from airflow.executors.workloads import ExecuteTask
20
20
  from airflow.models.taskinstancekey import TaskInstanceKey
21
21
  from airflow.utils.state import TaskInstanceState
22
-
23
- from airflow_unicore_integration.hooks import unicore_hooks
22
+ from pyunicore import client
23
+ from pyunicore import credentials
24
24
 
25
25
  from ..util.job import JobDescriptionGenerator
26
26
  from ..util.job import NaiveJobDescriptionGenerator
@@ -39,9 +39,14 @@ STATE_MAPPINGS: Dict[uc_client.JobStatus, TaskInstanceState] = {
39
39
 
40
40
  class UnicoreExecutor(BaseExecutor):
41
41
 
42
+ EXECUTOR_CONFIG_UNICORE_CONN_KEY = (
43
+ "unicore_connection_id" # alternative connection id for the Unicore connection to use
44
+ )
45
+ EXECUTOR_CONFIG_UNICORE_SITE_KEY = "unicore_site" # alternative Unicore site to run at, only required if different than connection default
46
+ EXECUTOR_CONFIG_UNICORE_CREDENTIAL_KEY = "unicore_credential" # alternative unicore credential to use for the job, only required if different than connection default
47
+
42
48
  def start(self):
43
49
  self.active_jobs: Dict[TaskInstanceKey, uc_client.Job] = {}
44
- self.uc_conn = unicore_hooks.UnicoreHook().get_conn()
45
50
  # TODO get job description generator class and init params from config
46
51
  self.job_descr_generator: JobDescriptionGenerator = NaiveJobDescriptionGenerator()
47
52
 
@@ -67,25 +72,26 @@ class UnicoreExecutor(BaseExecutor):
67
72
  return []
68
73
 
69
74
  def _get_unicore_client(self, executor_config: dict | None = {}):
70
- # TODO fix this only temporary solution
71
- return self.uc_conn
72
- # END TODO fix this
73
- # include client desires from executor_config
74
- unicore_conn_id = executor_config.get( # type: ignore
75
- UnicoreExecutor.EXECUTOR_CONFIG_UNICORE_CONN_KEY,
76
- conf.get("unicore.executor", "UNICORE_CONN_ID"),
77
- ) # task can provide a different unicore connection to use, else airflow-wide default is used
78
- self.log.info(f"Using base unicore connection with id '{unicore_conn_id}'")
79
- hook = unicore_hooks.UnicoreHook(uc_conn_id=unicore_conn_id)
80
- unicore_site = executor_config.get( # type: ignore
75
+ overwrite_unicore_site = executor_config.get( # type: ignore
81
76
  UnicoreExecutor.EXECUTOR_CONFIG_UNICORE_SITE_KEY, None
82
77
  ) # task can provide a different site to run at, else default from connetion is used
83
- unicore_credential = executor_config.get( # type: ignore
78
+ overwrite_unicore_credential = executor_config.get( # type: ignore
84
79
  UnicoreExecutor.EXECUTOR_CONFIG_UNICORE_CREDENTIAL_KEY, None
85
80
  ) # task can provide a different credential to use, else default from connection is used
86
- return hook.get_conn(
87
- overwrite_base_url=unicore_site, overwrite_credential=unicore_credential
81
+ user = conf.get("unicore.executor", "DEFAULT_USER", fallback="demouser")
82
+ password = conf.get("unicore.executor", "DEFAULT_PASS", fallback="test123")
83
+ base_url = conf.get(
84
+ "unicore.executor", "DEFAULT_URL", fallback="http://localhost:8080/DEMO-SITE/rest/core"
88
85
  )
86
+ credential = credentials.UsernamePassword(user, password)
87
+ if overwrite_unicore_site is not None:
88
+ base_url = overwrite_unicore_site
89
+ if overwrite_unicore_credential is not None:
90
+ credential = overwrite_unicore_credential
91
+ if not base_url:
92
+ raise TypeError()
93
+ conn = client.Client(credential, base_url)
94
+ return conn
89
95
 
90
96
  def _submit_job(self, workload: ExecuteTask):
91
97
  uc_client = self._get_unicore_client(executor_config=workload.ti.executor_config)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: airflow-unicore-integration
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Running Unicore Jobs from airflow DAGs.
5
5
  Author-email: Christian Böttcher <c.boettcher@fz-juelich.de>
6
6
  License-Expression: BSD-3-Clause
@@ -1,16 +1,16 @@
1
- airflow_unicore_integration/__init__.py,sha256=sibcOlQKBCUKfTbZlAl0L7r1d2nxf0nGAQys612vzeA,429
1
+ airflow_unicore_integration/__init__.py,sha256=Qy1mlyxe2Y-PPSn0LgIW0sT6BxFuwW4_LGsPBf-Wm4s,549
2
2
  airflow_unicore_integration/executors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  airflow_unicore_integration/executors/run_task_via_supervisor.py,sha256=3ErgPf-Oy3B4Di5yNXhhPkaojIJykvCxMZ9MlKSYPI8,2756
4
- airflow_unicore_integration/executors/unicore_executor.py,sha256=f2PKj66tZlWb39xF5YacEBoZ2-eZ_JR9pnKQwNHAybc,5619
4
+ airflow_unicore_integration/executors/unicore_executor.py,sha256=QNfF5sW4fRou89Hjo7j7SbfsXBo4fW3F4hkgbThrY6c,6008
5
5
  airflow_unicore_integration/hooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  airflow_unicore_integration/hooks/unicore_hooks.py,sha256=JjcjogWtN1xveagpkraQuYOdXjkp2lSnEdQc0waqhU4,1662
7
7
  airflow_unicore_integration/operators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  airflow_unicore_integration/operators/unicore_operators.py,sha256=xYX1t_QzjpqHZDoEu6jJNNXVmBEnjIlApFWvgYoYoB0,16790
9
9
  airflow_unicore_integration/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  airflow_unicore_integration/util/job.py,sha256=BSP-XuWL5-TRGACX__MavIcmPAA52gYLdwWL236cVz8,6703
11
- airflow_unicore_integration-0.1.5.dist-info/licenses/LICENSE,sha256=hZ5ouAedeNr8ClHrQE-RLsgMsARcmv3kSZz7tE2BTJE,1526
12
- airflow_unicore_integration-0.1.5.dist-info/METADATA,sha256=ZtH2sUzOSHxsDmVSIgb-yJ61i7bi9Zc2olzdPhaeMHE,11188
13
- airflow_unicore_integration-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- airflow_unicore_integration-0.1.5.dist-info/entry_points.txt,sha256=PzEfCLYLSawjiYR-HNBzw8-YGfJxs1nPBULevgBQjoY,147
15
- airflow_unicore_integration-0.1.5.dist-info/top_level.txt,sha256=j45X-uIuOk3oL78iwlpHakMWtUkg__B7zUlJLwmZx6w,28
16
- airflow_unicore_integration-0.1.5.dist-info/RECORD,,
11
+ airflow_unicore_integration-0.1.7.dist-info/licenses/LICENSE,sha256=hZ5ouAedeNr8ClHrQE-RLsgMsARcmv3kSZz7tE2BTJE,1526
12
+ airflow_unicore_integration-0.1.7.dist-info/METADATA,sha256=abUzAW9IfF_GXeiC1DdtUxxKxjAIfj9vJ8WzfBjQPu8,11188
13
+ airflow_unicore_integration-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ airflow_unicore_integration-0.1.7.dist-info/entry_points.txt,sha256=PzEfCLYLSawjiYR-HNBzw8-YGfJxs1nPBULevgBQjoY,147
15
+ airflow_unicore_integration-0.1.7.dist-info/top_level.txt,sha256=j45X-uIuOk3oL78iwlpHakMWtUkg__B7zUlJLwmZx6w,28
16
+ airflow_unicore_integration-0.1.7.dist-info/RECORD,,