Skip to content

Commit

Permalink
Merge pull request #126 from nextmv-io/develop
Browse files Browse the repository at this point in the history
Release v0.20.4
  • Loading branch information
sebastian-quintero authored Nov 9, 2022
2 parents e3968ca + 29e0d52 commit 6862cf0
Show file tree
Hide file tree
Showing 118 changed files with 16,334 additions and 664 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/go-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
RESOURCES: resources
NEXTMV_LIBRARY_PATH: ~/.nextmv/lib
GOVERSION: 1.19.2
# Use a matrix strategy to test all the modules simultaneously.
strategy:
fail-fast: false
Expand All @@ -31,7 +32,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: ${{ env.GOVERSION }}
id: go

- name: setup SSH Keys and known_hosts
Expand All @@ -49,7 +50,7 @@ jobs:

# Gets the token and stores it in a variable.
- name: export local branch
run: echo "BRANCH_CHECK=$(git ls-remote --heads https://github.com/nextmv-io/plugins ${{ env.LOCAL_BRANCH }})" >> $GITHUB_ENV
run: echo "BRANCH_CHECK=$(git ls-remote --heads https://github.com/nextmv-io/platform ${{ env.LOCAL_BRANCH }})" >> $GITHUB_ENV

# We always want to fall back to develop, even when the branch is stable,
# which means we are syncing a hotfix back on to develop.
Expand All @@ -60,10 +61,10 @@ jobs:
- name: git clone
uses: actions/checkout@v3

- name: clone plugins repository
- name: clone platform repository
uses: actions/checkout@v3
with:
repository: nextmv-io/plugins
repository: nextmv-io/platform
path: ${{ env.RESOURCES }}
ref: ${{ env.LOCAL_BRANCH }}
ssh-key: ${{ secrets.NEXTMVBOT_SSH_KEY }}
Expand All @@ -75,12 +76,15 @@ jobs:
- name: build plugins
run: |
# To get testing working, the dependency that plugins uses for sdk is
# replaced for the local sdk repo checked out in this action.
# To get testing working, the dependency that platform uses for sdk
# is replaced for the local sdk repo checked out in this action.
go mod edit -replace=github.com/nextmv-io/sdk=${{env.SDK_PATH}}
# Build the plugins.
REMOVE_TRIMPATH=1 NO_HIGHS_TODAY=1 NEXTMV_LIBRARY_PATH=${{ env.NEXTMV_LIBRARY_PATH }} bash scripts/build.sh > /dev/null 2>&1
REMOVE_TRIMPATH=1 \
NEXTMV_LIBRARY_PATH=${{ env.NEXTMV_LIBRARY_PATH }} \
GOVERSION=${{ env.GOVERSION }} \
bash scripts/build-plugins.sh > /dev/null 2>&1
working-directory: ${{env.RESOURCES}}

- name: go build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.19.2
id: go

- name: git clone
Expand All @@ -22,5 +22,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
version: v1.50.1
working-directory: ${{ matrix.MOD_PATH }}
19 changes: 19 additions & 0 deletions .github/workflows/json-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: json lint
on: [push]
jobs:
sdk-json-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v3

- name: set up node
uses: actions/setup-node@v3
with:
node-version: 16.17.1

- name: install prettier
run: npm install [email protected] --global

- name: lint .json files with prettier
run: prettier -c "**/*.json"
2 changes: 0 additions & 2 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ jobs:
sdk-markdown-lint:
runs-on: ubuntu-latest
steps:
# Checkout the changes
- name: git clone
uses: actions/checkout@v3

# Use markdownlint-cli2
- uses: DavidAnson/markdownlint-cli2-action@v7
with:
globs: "**/*.md"
5 changes: 2 additions & 3 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ name: merge check stable branch
on:
pull_request:
types: [opened, ready_for_review]
branches: [stable]
jobs:
sdk-stable-merge-check:
runs-on: ubuntu-latest
steps:
- name: check that head branch is allowed
if: ${{ github.head_ref != 'develop' && startsWith(github.head_ref, 'hotfix/') == false }}
if: ${{ github.base_ref == 'stable' && github.head_ref != 'develop' && startsWith(github.head_ref, 'hotfix/') == false }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('merging to stable is only allowed from: develop, hotfix/*')
core.setFailed('target branch is stable and only these branches are allowed to merge: develop, hotfix/*')
59 changes: 53 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ linters:
- containedctx
# Check the function whether use a non-inherited context.
- contextcheck
# Finds unused code.
- deadcode
# Finds unused code. WARN [runner] The linter 'deadcode' is deprecated
# (since v1.49.0) due to: The owner seems to have abandoned the linter.
# Replaced by unused.
# - deadcode
# check declaration order and count of types, constants, variables and functions.
- decorder
# Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
Expand Down Expand Up @@ -119,8 +121,10 @@ linters:
- revive
# Staticcheck is a go vet on steroids, applying a ton of static analysis checks.
- staticcheck
# Finds unused struct fields.
- structcheck
# Finds unused struct fields. WARN [runner] The linter 'structcheck' is
# deprecated (since v1.49.0) due to: The owner seems to have abandoned the
# linter. Replaced by unused.
# - structcheck
# Stylecheck is a replacement for golint.
- stylecheck
# Checks the struct tags.
Expand All @@ -133,8 +137,10 @@ linters:
- unparam
# Checks Go code for unused constants, variables, functions and types.
- unused
# Finds unused global variables and constants.
- varcheck
# Finds unused global variables and constants. WARN [runner] The linter
# 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have
# abandoned the linter. Replaced by unused.
# - varcheck
# wastedassign finds wasted assignment statements.
- wastedassign
# Tool for detection of leading and trailing whitespace.
Expand Down Expand Up @@ -176,3 +182,44 @@ issues:
# linting is ignored by using the following syntax on a line: //nolint. If
# you look for uses of //nolint you will find the other linting issues
# being excluided.

# TODO: fix cyclomatic complexity issues on these templates. This linter is
# ignored for expediency.
- path: templates/cloud-routing/helper\.go
linters:
- gocyclo
- path: templates/cloud-routing/schema\.go
linters:
- gocyclo
- path: templates/cloud-routing/solver\.go
linters:
- gocyclo
- path: templates/mip-knapsack/main\.go
linters:
- gocyclo
- path: templates/mip-meal-allocation/main\.go
linters:
- gocyclo
- path: templates/pager-duty/main\.go
linters:
- gocyclo
- path: templates/shift-scheduling/main\.go
linters:
- gocyclo
- path: templates/sudoku/main\.go
linters:
- gocyclo

# TODO: figure out a better way to Marshal to JSON with some sort of error
# checking.
- path: templates/cloud-routing/schema\.go
linters:
- unparam
text: cloudDuration

# The linter suggests switching an if-elseif-else statement to use switch.
# This is not reasonable right now because the conditions are complex.
- path: templates/cloud-routing/helper\.go
linters:
- gocritic
text: ifElseChain
1 change: 1 addition & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tabWidth: 2
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ problems. Please find the following packages:
- [run][run]: convenient runners that read an input, run a solver and write an
output.
- [model][model]: modeling components such as integer domains and ranges.
- [mip][mip]: Mixed-Integer Programming API with various solvers.
- [templates][templates]: ready-to-go applications for solving various types of
decision automation problems. Designed to work with the [Nextmv CLI][cli].
- [inputs][inputs]: `.json` inputs for working with the Nextmv routing app.
Designed to work with the [Nextmv CLI][cli].

Please visit the official [Nextmv docs][docs] for comprehensive information.

Expand All @@ -24,4 +29,8 @@ go get github.com/nextmv-io/sdk
[route]: ./route
[run]: ./run
[model]: ./model
[mip]: ./mip
[templates]: ./templates
[inputs]: ./inputs
[docs]: https://docs.nextmv.io
[cli]: https://docs.nextmv.io/reference/cli
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.20.3
v0.20.4
33 changes: 33 additions & 0 deletions dataframe/aggregation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package dataframe

import "fmt"

// Aggregation defines how to aggregate rows of a group of rows in a Groups
// instance.
type Aggregation interface {
fmt.Stringer

// Column returns the column the aggregation will be applied to.
Column() Column

// As returns the column to be used to identify the newly created column.
// containing the aggregated value.
As() Column
}

// Aggregations is the slice of Aggregation instances.
type Aggregations []Aggregation

// NumericAggregations defines the possible aggregations which can be applied on
// columns of type Float and Int.
type NumericAggregations interface {
// Max creates an aggregation which reports the maximum value using
// name as.
Max(as string) Aggregation
// Min creates an aggregation which reports the minimum value using
// name as.
Min(as string) Aggregation
// Sum creates an aggregation which reports the sum of values using
// name as.
Sum(as string) Aggregation
}
130 changes: 130 additions & 0 deletions dataframe/column.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package dataframe

import (
"fmt"

"github.com/nextmv-io/sdk/connect"
)

// Bools returns a BoolColumn identified by name.
func Bools(name string) BoolColumn {
connect.Connect(con, &newBoolColumn)
return newBoolColumn(name)
}

// Floats returns a FloatColumn identified by name.
func Floats(name string) FloatColumn {
connect.Connect(con, &newFloatColumn)
return newFloatColumn(name)
}

// Ints returns a IntColumn identified by name.
func Ints(name string) IntColumn {
connect.Connect(con, &newIntColumn)
return newIntColumn(name)
}

// Strings returns a StringColumn identified by name.
func Strings(name string) StringColumn {
connect.Connect(con, &newStringColumn)
return newStringColumn(name)
}

// DataType defines the types of colums available in DataFrame.
type DataType string

// Types of data in DataFrame.
const (
// Bool type representing boolean true and false values.
Bool DataType = "bool"
// Int type representing int values.
Int = "int"
// Float type representing float64 values.
Float = "float"
// String type representing string values.
String = "string"
)

// Column is a single column in a DataFrame instance. It is identified by its
// name and has a DataType.
type Column interface {
fmt.Stringer

// Name returns the name of the column, the name is the unique identifier
// of the column within a DataFrame instance.
Name() string

// DataType returns the type of the column.
DataType() DataType
}

// Columns is the slice of Column instances.
type Columns []Column

// BoolColumn is the typed column of type Bool.
type BoolColumn interface {
Column

// IsFalse creates a filter to filter all rows having value false.
IsFalse() Filter
// IsTrue creates a filter to filter all rows having value true.
IsTrue() Filter

// Value return the value at row for dataframe df,
// panics if out of bound.
Value(df DataFrame, row int) bool

// Values returns all the values in the column for dataframe df.
Values(df DataFrame) []bool
}

// FloatColumn is the typed column of type Float.
type FloatColumn interface {
Column
NumericAggregations

// IsInRange creates a filter to filter all rows within range [min, max].
IsInRange(min, max float64) Filter

// Value return the value at row, panics if out of bound.
Value(df DataFrame, row int) float64

// Values returns all the values in the column.
Values(df DataFrame) []float64
}

// IntColumn is the typed column of type Int.
type IntColumn interface {
Column
NumericAggregations

// IsInRange creates a filter to filter all value within range [min, max].
IsInRange(min, max int) Filter

// Value return the value at row, panics if out of bound.
Value(df DataFrame, row int) int

// Values returns all the values in the column.
Values(df DataFrame) []int
}

// StringColumn is the typed column of type String.
type StringColumn interface {
Column

// Equals creates a filter to filter all rows having value value.
Equals(value string) Filter

// Value return the value at row, panics if out of bound.
Value(df DataFrame, row int) *string

// Values returns all the values in the column.
Values(df DataFrame) []*string
}

var (
newBoolColumn func(string) BoolColumn
newFloatColumn func(string) FloatColumn
newIntColumn func(string) IntColumn
newStringColumn func(string) StringColumn
)
Loading

0 comments on commit 6862cf0

Please sign in to comment.