Skip to content

Commit

Permalink
Merge pull request #9 from ivan-valkov/linters
Browse files Browse the repository at this point in the history
Add golangci-lint linters and fix existing lint failures
  • Loading branch information
ukclivecox authored Nov 25, 2021
2 parents 9aa7433 + 2ba34de commit 6cbe43d
Show file tree
Hide file tree
Showing 49 changed files with 1,129 additions and 959 deletions.
2 changes: 2 additions & 0 deletions operator/.errcheck_excludes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fmt.Fprintln
fmt.Fprint
46 changes: 46 additions & 0 deletions operator/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs: vendor

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

linters:
disable-all: true
enable:
# Sorted alphabetically.
- errcheck
- exportloopref
- goimports # Also includes gofmt style formatting
- gosimple
- govet
- misspell
- staticcheck
- structcheck
- typecheck
- varcheck

linters-settings:
errcheck:
exclude: ./.errcheck_excludes.txt
goconst:
min-occurrences: 5
4 changes: 4 additions & 0 deletions operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

.PHONY: lint
lint: ## Run go linters against code.
golangci-lint run --fix

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
Expand Down
6 changes: 3 additions & 3 deletions operator/apis/mlops/v1alpha1/explainer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
// ExplainerSpec defines the desired state of Explainer
type ExplainerSpec struct {
ModelSpec `json:",inline"`
BlackBox *BlackBox `json:"blackbox,omitempty"`
WhiteBox *WhiteBox `json:"whitebox,omitempty"`
BlackBox *BlackBox `json:"blackbox,omitempty"`
WhiteBox *WhiteBox `json:"whitebox,omitempty"`
}

// Either ModelRef or PipelineRef is required
Expand All @@ -41,7 +41,7 @@ type BlackBox struct {
type WhiteBox struct {
// Storage URI for the model repository
// +optional
InferenceArtifactSpec`json:",inline"`
InferenceArtifactSpec `json:",inline"`
}

// ExplainerStatus defines the observed state of Explainer
Expand Down
3 changes: 0 additions & 3 deletions operator/apis/mlops/v1alpha1/model_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,3 @@ type ModelList struct {
func init() {
SchemeBuilder.Register(&Model{}, &ModelList{})
}



12 changes: 6 additions & 6 deletions operator/apis/mlops/v1alpha1/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
// TODO do we need autoscaling spec?
type ServerSpec struct {
// Server definition
Server ServerDefn `json:"server,omitempty"`
Server ServerDefn `json:"server,omitempty"`
// Either Models or Mesh needs to be provides
// Preloaded models for non mesh server
Models []PreLoadedModelSpec `json:"models,omitempty"`
Models []PreLoadedModelSpec `json:"models,omitempty"`
// Seldon mesh specifications for mesh servers that can load models dynamically
Mesh *MeshDefn `json:"mesh"`
Mesh *MeshDefn `json:"mesh"`
// PodSpec overrides
PodOverride PodSpec `json:"podSpec,omitempty"`
// Number of replicas - defaults to 1
Expand All @@ -40,7 +40,7 @@ type ServerSpec struct {
type PreLoadedModelSpec struct {
// Name override
// +optional
Name *string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
InferenceArtifactSpec `json:",inline"`
}

Expand All @@ -59,10 +59,10 @@ type MeshDefn struct {

type ServerDefn struct {
// Server type - mlserver, triton or left out if custom container
Type *string `json:"type,omitempty"`
Type *string `json:"type,omitempty"`
// +optional
RuntimeVersion *string `json:"runtimeVersion,omitempty"`
// Conatiner overrides for server
// Container overrides for server
Container *v1.Container `json:"container,omitempty"`
}

Expand Down
121 changes: 102 additions & 19 deletions operator/apis/mlops/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions operator/config/crd/bases/mlops.seldon.io_explainers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ spec:
description: Reference to Pipeline step - must include pipeline
type: string
type: object
dedicated:
description: Dedicated server exclusive to this model Default false
type: boolean
logger:
description: Payload logging
properties:
percent:
description: Percentage of payloads to log Defaults to 100%
format: int32
type: integer
uri:
description: URI to logging endpoint.
type: string
type: object
maxReplicas:
description: Max number of replicas - default equal to replicas
format: int32
Expand Down
14 changes: 14 additions & 0 deletions operator/config/crd/bases/mlops.seldon.io_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ spec:
spec:
description: ModelSpec defines the desired state of Model
properties:
dedicated:
description: Dedicated server exclusive to this model Default false
type: boolean
logger:
description: Payload logging
properties:
percent:
description: Percentage of payloads to log Defaults to 100%
format: int32
type: integer
uri:
description: URI to logging endpoint.
type: string
type: object
maxReplicas:
description: Max number of replicas - default equal to replicas
format: int32
Expand Down
3 changes: 3 additions & 0 deletions operator/config/crd/bases/mlops.seldon.io_pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ spec:
description: The steps of this inference graph pipeline
items:
properties:
async:
description: Whether this step is asynchronous
type: boolean
if:
description: Condition specification to satisfy for this step
to be run
Expand Down
2 changes: 1 addition & 1 deletion operator/config/crd/bases/mlops.seldon.io_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8906,7 +8906,7 @@ spec:
description: Server definition
properties:
container:
description: Conatiner overrides for server
description: Container overrides for server
properties:
args:
description: 'Arguments to the entrypoint. The docker image''s
Expand Down
Loading

0 comments on commit 6cbe43d

Please sign in to comment.