Skip to content

Commit

Permalink
feat: Batch Support (#683)
Browse files Browse the repository at this point in the history
* Add Batch API to nitric core
* feat(aws): Batch services (#675)
* feat(gcp): Batch services (#676)

---------

Co-authored-by: Jye Cusch <[email protected]>
Co-authored-by: David Moore <[email protected]>
Co-authored-by: Ryan Cartwright <[email protected]>
  • Loading branch information
4 people authored Oct 3, 2024
1 parent 42c1e48 commit 76ea627
Show file tree
Hide file tree
Showing 81 changed files with 5,747 additions and 2,658 deletions.
11 changes: 6 additions & 5 deletions cloud/aws/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
run:
timeout: "5m"
skip-files:
- tools/tools.go
skip-dirs:
- deploytf/generated
go: 1.18
go: 1.21

linters:
disable-all: true
Expand All @@ -23,6 +19,11 @@ linters:
- errorlint

issues:
exclude-dirs:
- deploytf/generated
- tools
exclude-files:
- tools/tools.go
max-issues-per-linter: 0
max-same-issues: 0

Expand Down
23 changes: 23 additions & 0 deletions cloud/aws/common/batch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2021 Nitric Technologies Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package common

import (
"fmt"
)

func GetJobDefinitionName(stackId string, jobName string) (string, error) {
return fmt.Sprintf("%s-job-%s", stackId, jobName), nil
}
27 changes: 26 additions & 1 deletion cloud/aws/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@ import (
)

type AwsApiConfig struct {
Domains []string
Description string
Domains []string
}

type AwsImports struct {
// A map of nitric names to ARNs
Secrets map[string]string
Buckets map[string]string
}

type BatchComputeEnvConfig struct {
MinCpus int `mapstructure:"min-cpus"`
MaxCpus int `mapstructure:"max-cpus"`
InstanceTypes []string `mapstructure:"instance-types"`
}

type AwsConfig struct {
ScheduleTimezone string `mapstructure:"schedule-timezone,omitempty"`
Import AwsImports
Refresh bool
Apis map[string]*AwsApiConfig
BatchComputeEnvConfig *BatchComputeEnvConfig `mapstructure:"batch-compute-env,omitempty"`
config.AbstractConfig[*AwsConfigItem] `mapstructure:"config,squash"`
}

Expand All @@ -62,6 +71,12 @@ var defaultLambdaConfig = &AwsLambdaConfig{
ProvisionedConcurreny: 0,
}

var defaultBatchComputeEnvConfig = &BatchComputeEnvConfig{
MinCpus: 0,
MaxCpus: 32,
InstanceTypes: []string{"optimal"},
}

var defaultAwsConfigItem = AwsConfigItem{
Telemetry: 0,
}
Expand Down Expand Up @@ -100,6 +115,16 @@ func ConfigFromAttributes(attributes map[string]interface{}) (*AwsConfig, error)
awsConfig.Config["default"].Lambda = defaultLambdaConfig
}

if awsConfig.BatchComputeEnvConfig == nil {
awsConfig.BatchComputeEnvConfig = defaultBatchComputeEnvConfig
}

// merge in default values
err = mergo.Merge(awsConfig.BatchComputeEnvConfig, defaultBatchComputeEnvConfig)
if err != nil {
return nil, err
}

for configName, configVal := range awsConfig.Config {
// Add omitted values from default configs where needed.
err := mergo.Merge(configVal, defaultAwsConfigItem)
Expand Down
Loading

0 comments on commit 76ea627

Please sign in to comment.