Skip to content

Commit

Permalink
v1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
brianloyal committed Jun 1, 2023
1 parent 28371b7 commit 28c2ff8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [1.10.1] - 2023-05-31

### 1.10.1 Fixed

- Added paginators to boto3 calls in batchfold environment class to address issue with deploying multiple stacks.

---

## [1.10.0] - 2023-05-25

### 1.10.0 Added
Expand Down
39 changes: 30 additions & 9 deletions src/batchfold/batchfold_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,46 @@ def load_latest_root_stack(self) -> str:
"ROLLBACK_COMPLETE",
"UPDATE_COMPLETE",
]
for stack in cfn.list_stacks(StackStatusFilter=stack_status_filter)["StackSummaries"]:
if "batch-protein-folding-cfn-root.yaml" in stack.get("TemplateDescription", []):
batchfold_stacks.append((stack["CreationTime"], stack["StackId"]))
return sorted(batchfold_stacks, key = lambda x: x[0], reverse=True)[0][1]

paginator = cfn.get_paginator("list_stacks")
pages = paginator.paginate(StackStatusFilter=stack_status_filter)

for page in pages:
for stack in page["StackSummaries"]:
if "batch-protein-folding-cfn-root.yaml" in stack.get(
"TemplateDescription", []
):
batchfold_stacks.append((stack["CreationTime"], stack["StackId"]))
return sorted(batchfold_stacks, key=lambda x: x[0], reverse=True)[0][1]

@nested_stacks.default
def load_nested_stacks(self) -> List:
cfn = self.boto_session.client("cloudformation")
resources = cfn.list_stack_resources(StackName=self.stack_id).get("StackResourceSummaries", [])
return [ x.get("PhysicalResourceId", []) for x in resources if x.get("ResourceType", []) == "AWS::CloudFormation::Stack" ]

paginator = cfn.get_paginator("list_stack_resources")
pages = paginator.paginate(StackName=self.stack_id)
resources = []

for page in pages:
resources.append(page.get("StackResourceSummaries", []))

return [
x.get("PhysicalResourceId", [])
for x in resources
if x.get("ResourceType", []) == "AWS::CloudFormation::Stack"
]

@stack_outputs.default
def load_stack_outputs(self) -> List:
cfn = self.boto_session.client("cloudformation")
stack_outputs = []
for nested_stack in self.nested_stacks:
stack_outputs.extend(cfn.describe_stacks(StackName=nested_stack).get("Stacks")[0].get("Outputs", []))
return(stack_outputs)
stack_outputs.extend(
cfn.describe_stacks(StackName=nested_stack)
.get("Stacks")[0]
.get("Outputs", [])
)
return stack_outputs

def get_stack_outputs(self, filter: str = "") -> Dict:
"""Get a dict of the cloudformation stack outputs, optionally with key filtered by a string"""
Expand Down Expand Up @@ -141,4 +163,3 @@ def list_jobs(
all_jobs[queue.name] = jobs

return all_jobs

0 comments on commit 28c2ff8

Please sign in to comment.