Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include MetricsUnavailable condition to Complete in Trial #1877

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions .github/workflows/test-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ on:
- pull_request

jobs:
test:
name: Test
generatetests:
name: Generate And Format Test
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/kubeflow/katib

steps:
- name: Check out code
uses: actions/checkout@v2
Expand All @@ -28,19 +27,47 @@ jobs:
# Verify that go.mod and go.sum is synchronized
- name: Check Go modules
run: |
if [[ ! -z $(go mod tidy && git diff --exit-code) ]]; then
echo "Please run "go mod tidy" to sync Go modules"
exit 1
fi
go mod tidy &&
git add go.* &&
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1)

- name: Run Go test
- name: Run Generate And Go Format Test
run: |
go mod download
make check
make test
go mod download &&
make check &&
git add pkg/apis hack/gen-python-sdk &&
git diff --cached --exit-code || (echo 'Please run "make check" to generate codes and to format Go codes' && exit 1)

unittests:
name: Unit Test
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/kubeflow/katib
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ${{ env.GOPATH }}/src/github.com/kubeflow/katib

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17.10

- name: Run Go test
run: go mod download && make test ENVTEST_K8S_VERSION=${{ matrix.kubernetes-version }}

- name: Coveralls report
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
working-directory: ${{ env.GOPATH }}/src/github.com/kubeflow/katib

strategy:
fail-fast: false
matrix:
# Detail: `setup-envtest list --arch amd64`
kubernetes-version: ["1.21.4", "1.22.1", "1.23.5"]
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ifndef HAS_SETUP_ENVTEST
endif
echo "setup-envtest has already installed"


check: generate fmt vet lint

fmt:
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/controller/experiments/v1beta1/experiment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ type ExperimentStatus struct {
// List of trial names which have been early stopped.
EarlyStoppedTrialList []string `json:"earlyStoppedTrialList,omitempty"`

// List of trial names which have been metrics unavailable
MetricsUnavailableTrialList []string `json:"metricsUnavailableTrialList,omitempty"`

// Trials is the total number of trials owned by the experiment.
Trials int32 `json:"trials,omitempty"`

Expand All @@ -120,6 +123,9 @@ type ExperimentStatus struct {

// How many trials are currently early stopped.
TrialsEarlyStopped int32 `json:"trialsEarlyStopped,omitempty"`

// How many trials are currently metrics unavailable.
TrialMetricsUnavailable int32 `json:"trialMetricsUnavailable,omitempty"`
}

// OptimalTrial is the metrics and assignments of the best trial.
Expand Down

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

13 changes: 7 additions & 6 deletions pkg/apis/controller/trials/v1beta1/trial_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ type TrialCondition struct {
type TrialConditionType string

const (
TrialCreated TrialConditionType = "Created"
TrialRunning TrialConditionType = "Running"
TrialSucceeded TrialConditionType = "Succeeded"
TrialKilled TrialConditionType = "Killed"
TrialFailed TrialConditionType = "Failed"
TrialEarlyStopped TrialConditionType = "EarlyStopped"
TrialCreated TrialConditionType = "Created"
TrialRunning TrialConditionType = "Running"
TrialSucceeded TrialConditionType = "Succeeded"
TrialKilled TrialConditionType = "Killed"
TrialFailed TrialConditionType = "Failed"
TrialMetricsUnavailable TrialConditionType = "MetricsUnavailable"
TrialEarlyStopped TrialConditionType = "EarlyStopped"
)

// +genclient
Expand Down
16 changes: 10 additions & 6 deletions pkg/apis/controller/trials/v1beta1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,11 @@ func (trial *Trial) IsKilled() bool {

// IsMetricsUnavailable returns true if Trial metrics are not available
func (trial *Trial) IsMetricsUnavailable() bool {
cond := getCondition(trial, TrialSucceeded)
if cond != nil && cond.Status == v1.ConditionFalse {
return true
}
return false
return hasCondition(trial, TrialMetricsUnavailable)
}

func (trial *Trial) IsCompleted() bool {
return trial.IsSucceeded() || trial.IsFailed() || trial.IsKilled() || trial.IsEarlyStopped()
return trial.IsSucceeded() || trial.IsFailed() || trial.IsKilled() || trial.IsEarlyStopped() || trial.IsMetricsUnavailable()
}

func (trial *Trial) IsEarlyStopped() bool {
Expand Down Expand Up @@ -158,3 +154,11 @@ func (trial *Trial) MarkTrialStatusKilled(reason, message string) {
}
trial.setCondition(TrialKilled, v1.ConditionTrue, reason, message)
}

func (trial *Trial) MarkTrialStatusMetricsUnavailable(reason, message string) {
currentCond := getCondition(trial, TrialRunning)
if currentCond != nil {
trial.setCondition(TrialRunning, v1.ConditionFalse, currentCond.Reason, currentCond.Message)
}
trial.setCondition(TrialMetricsUnavailable, v1.ConditionTrue, reason, message)
}
Loading