Skip to content

Commit

Permalink
shorter jinja variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPlayer3 committed Aug 27, 2024
1 parent 4ce4abe commit 8ff4a7d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
24 changes: 12 additions & 12 deletions apps/compute-cf.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ Outputs:
Value: !Ref SharedJobQueue

{% for job_type, job_spec in job_types.items() if 'Shared' not in job_spec['compute_environment']['name'] %}
{% set job_name = job_spec['compute_environment']['name'] %}
{{ job_name }}ComputeEnvironmentArn:
Value: !Ref {{ job_name }}ComputeEnvironment
{% set name = job_spec['compute_environment']['name'] %}
{{ name }}ComputeEnvironmentArn:
Value: !Ref {{ name }}ComputeEnvironment

{{ job_name }}JobQueueArn:
Value: !Ref {{ job_name }}JobQueue
{{ name }}JobQueueArn:
Value: !Ref {{ name }}JobQueue

{% endfor %}

Expand Down Expand Up @@ -109,10 +109,10 @@ Resources:

{% for job_type, job_spec in job_types.items() if 'Shared' not in job_spec['compute_environment']['name'] %}
{% set env = job_spec['compute_environment'] %}
{% set job_name = env['name'] %}
{% set name = env['name'] %}
{% set instance_types = env['instance_types'] if 'instance_types' in env else ['!Ref InstanceTypes'] %}
{% set ami_id = env['ami_id'] if 'ami_id' in env else '!Ref AmiId' %}
{{ job_name }}LaunchTemplate:
{{ name }}LaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
Expand All @@ -136,7 +136,7 @@ Resources:

--==BOUNDARY==--

{{ job_name }}ComputeEnvironment:
{{ name }}ComputeEnvironment:
Type: AWS::Batch::ComputeEnvironment
Properties:
ServiceRole: !GetAtt BatchServiceRole.Arn
Expand All @@ -156,17 +156,17 @@ Resources:
SecurityGroupIds:
- !Ref SecurityGroup
LaunchTemplate:
LaunchTemplateId: !Ref {{ job_name }}LaunchTemplate
Version: !GetAtt {{ job_name }}LaunchTemplate.LatestVersionNumber
LaunchTemplateId: !Ref {{ name }}LaunchTemplate
Version: !GetAtt {{ name }}LaunchTemplate.LatestVersionNumber
Tags:
Name: !Ref AWS::StackName

{{ job_name }}JobQueue:
{{ name }}JobQueue:
Type: AWS::Batch::JobQueue
Properties:
Priority: 1
ComputeEnvironmentOrder:
- ComputeEnvironment: !Ref {{ job_name }}ComputeEnvironment
- ComputeEnvironment: !Ref {{ name }}ComputeEnvironment
Order: 1
SchedulingPolicyArn: !Ref SchedulingPolicy

Expand Down
12 changes: 6 additions & 6 deletions apps/main-cf.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ Resources:
Parameters:
ComputeEnvironmentArn: !GetAtt Cluster.Outputs.SharedComputeEnvironmentArn
{% for job_type, job_spec in job_types.items() if 'Shared' not in job_spec['compute_environment']['name'] %}
{% set job_name = job_spec['compute_environment']['name'] %}
{{ job_name }}ComputeEnvironmentArn: !GetAtt Cluster.Outputs.{{ job_name }}ComputeEnvironmentArn
{% set name = job_spec['compute_environment']['name'] %}
{{ name }}ComputeEnvironmentArn: !GetAtt Cluster.Outputs.{{ name }}ComputeEnvironmentArn
{% endfor %}
DefaultMaxvCpus: !Ref DefaultMaxvCpus
ExpandedMaxvCpus: !Ref ExpandedMaxvCpus
Expand All @@ -174,8 +174,8 @@ Resources:
Parameters:
JobQueueArn: !GetAtt Cluster.Outputs.SharedJobQueueArn
{% for job_type, job_spec in job_types.items() if 'Shared' not in job_spec['compute_environment']['name'] %}
{% set job_name = job_spec['compute_environment']['name'] %}
{{ job_name }}JobQueueArn: !GetAtt Cluster.Outputs.{{ job_name }}JobQueueArn
{% set name = job_spec['compute_environment']['name'] %}
{{ name }}JobQueueArn: !GetAtt Cluster.Outputs.{{ name }}JobQueueArn
{% endfor %}
JobsTable: !Ref JobsTable
{% if security_environment == 'EDC' %}
Expand All @@ -190,8 +190,8 @@ Resources:
Parameters:
SharedJobQueueArn: !GetAtt Cluster.Outputs.SharedJobQueueArn
{% for job_type, job_spec in job_types.items() if 'Shared' not in job_spec['compute_environment']['name'] %}
{% set job_name = job_spec['compute_environment']['name'] %}
{{ job_name }}JobQueueArn: !GetAtt Cluster.Outputs.{{ job_name }}JobQueueArn
{% set name = job_spec['compute_environment']['name'] %}
{{ name }}JobQueueArn: !GetAtt Cluster.Outputs.{{ name }}JobQueueArn
{% endfor %}
TaskRoleArn: !GetAtt Cluster.Outputs.TaskRoleArn
JobsTable: !Ref JobsTable
Expand Down
3 changes: 2 additions & 1 deletion apps/workflow-cf.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ Resources:
DefinitionSubstitutions:
SharedJobQueueArn: !Ref SharedJobQueueArn
{% for job_type, job_spec in job_types.items() if 'Shared' not in job_spec['compute_environment']['name'] %}
{{ job_spec['compute_environment']['name'] }}JobQueueArn: !Ref {{ job_spec['compute_environment']['name'] }}JobQueueArn
{% set name = job_spec['compute_environment']['name'] %}
{{ name }}JobQueueArn: !Ref {{ name }}JobQueueArn
{% endfor %}
{% for job_type, job_spec in job_types.items() %}
{% for task in job_spec['tasks'] %}
Expand Down

0 comments on commit 8ff4a7d

Please sign in to comment.