Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Bug: filter job submission clusters out of cluster list (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafreck authored Mar 9, 2018
1 parent f1e3f7a commit 1c31335
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions aztk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def __create_pool_and_job(self, cluster_conf: models.ClusterConfiguration, softw
metadata=[
batch_models.MetadataItem(
name=constants.AZTK_SOFTWARE_METADATA_KEY, value=software_metadata_key),
batch_models.MetadataItem(
name=constants.AZTK_MODE_METADATA_KEY, value=constants.AZTK_CLUSTER_MODE_METADATA)
])

# Create the pool + create user for the pool
Expand Down Expand Up @@ -140,10 +142,13 @@ def __list_clusters(self, software_metadata_key):
pools = self.batch_client.pool.list()
software_metadata = (
constants.AZTK_SOFTWARE_METADATA_KEY, software_metadata_key)
cluster_metadata = (
constants.AZTK_MODE_METADATA_KEY, constants.AZTK_CLUSTER_MODE_METADATA)

aztk_pools = []
for pool in [pool for pool in pools if pool.metadata]:
if software_metadata in [(metadata.name, metadata.value) for metadata in pool.metadata]:
pool_metadata = [(metadata.name, metadata.value) for metadata in pool.metadata]
if all([metadata in pool_metadata for metadata in [software_metadata, cluster_metadata]]):
aztk_pools.append(pool)
return aztk_pools

Expand Down Expand Up @@ -300,7 +305,9 @@ def __submit_job(self,
max_tasks_per_node=1,
metadata=[
batch_models.MetadataItem(
name=constants.AZTK_SOFTWARE_METADATA_KEY, value=software_metadata_key)
name=constants.AZTK_SOFTWARE_METADATA_KEY, value=software_metadata_key),
batch_models.MetadataItem(
name=constants.AZTK_MODE_METADATA_KEY, value=constants.AZTK_JOB_MODE_METADATA)
]
)
)
Expand Down
4 changes: 4 additions & 0 deletions aztk/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@

AZTK_SOFTWARE_METADATA_KEY = "_aztk_software"

AZTK_MODE_METADATA_KEY = "_aztk_mode"
AZTK_CLUSTER_MODE_METADATA = "cluster"
AZTK_JOB_MODE_METADATA = "job"

AZTK_CLUSTER_CONFIG_METADATA_KEY = "_aztk_cluster_config"

TASK_WORKING_DIR = "wd"
Expand Down

0 comments on commit 1c31335

Please sign in to comment.