Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Standalone CLI: sub #232

Merged
merged 34 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
897a175
Add ai cli
nstogner Sep 3, 2023
4bcf58f
Refactor API
nstogner Sep 4, 2023
93f157c
Working Notebook from Dataset
nstogner Sep 4, 2023
ae83899
CLI: strat notebook & run - working
nstogner Sep 6, 2023
2dcf969
Add cli.md
nstogner Sep 6, 2023
5212899
Update cli.md
nstogner Sep 6, 2023
5168394
Add list command
nstogner Sep 7, 2023
3edfd7e
Add infer cmd and Pod watches to notebook cmd
nstogner Sep 8, 2023
5859c36
Update output/ to artifacts/ and add build logging to nb
nstogner Sep 9, 2023
0fce641
Fix logging
nstogner Sep 9, 2023
7563ff2
update cli build steps for linux
samos123 Sep 10, 2023
ce382ba
Add versioning to run cmd and stub out deletion cmd
nstogner Sep 10, 2023
a914f8d
Add failure tracking, remove kubectl/, fix tests
nstogner Sep 10, 2023
7da35c6
Multi-version list
nstogner Sep 10, 2023
fc7810c
CLI renaming
nstogner Sep 11, 2023
c29063b
add env support sub cli
samos123 Sep 11, 2023
b8aea97
Improve sub-get
nstogner Sep 12, 2023
22fb0c4
Sync all directories other than mounts
nstogner Sep 13, 2023
78e98d3
Refactor - broken
nstogner Sep 18, 2023
5f8aca0
Fix
nstogner Sep 20, 2023
34b37db
Consolidate styles
nstogner Sep 23, 2023
870e88c
Stop nbwatch from syncing dot-dirs, refactor CLI to prepare for delet…
nstogner Sep 24, 2023
2f79e4e
Flatten internal/*
nstogner Sep 24, 2023
497d4c4
Checkpoint
nstogner Sep 24, 2023
a91ca7c
Refactor manifest loading
nstogner Sep 24, 2023
7a83942
Hacky deletion working
nstogner Sep 24, 2023
c180414
refactor examples
samos123 Sep 26, 2023
082e236
Sub serve - working
nstogner Sep 26, 2023
9a1a2d0
Fix integration tests, add Substratus manifest searching
nstogner Sep 27, 2023
68b21ca
change sub apply to sub push
nstogner Sep 28, 2023
314253e
Bump go versions in Dockerfiles
nstogner Sep 29, 2023
af555dd
fix integration tests
samos123 Sep 30, 2023
d93a4dc
Address comments
nstogner Sep 30, 2023
9b59ddd
Update goreleaser
nstogner Sep 30, 2023
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ dev-down-aws: build-installer
.PHONY: dev-run-gcp
# Controller manager configuration #
dev-run-gcp: export CLOUD=gcp
dev-run-gcp: PROJECT_ID ?= $(shell gcloud config get project)
samos123 marked this conversation as resolved.
Show resolved Hide resolved
dev-run-gcp: export PROJECT_ID=$(shell gcloud config get project)
dev-run-gcp: export CLUSTER_NAME=substratus
dev-run-gcp: export CLUSTER_LOCATION=us-central1
dev-run-gcp: export PRINCIPAL=substratus@${PROJECT_ID}.iam.gserviceaccount.com
Expand Down
6 changes: 3 additions & 3 deletions api/v1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package v1
const (
ConditionUploaded = "Uploaded"
ConditionBuilt = "Built"
ConditionLoaded = "Loaded"
ConditionModelled = "Modelled"
ConditionDeployed = "Deployed"
ConditionComplete = "Complete"
ConditionServing = "Serving"
)

const (
Expand All @@ -20,6 +19,7 @@ const (

ReasonJobNotComplete = "JobNotComplete"
ReasonJobComplete = "JobComplete"
ReasonJobFailed = "JobFailed"
ReasonDeploymentReady = "DeploymentReady"
ReasonDeploymentNotReady = "DeploymentNotReady"
ReasonPodReady = "PodReady"
Expand Down
7 changes: 4 additions & 3 deletions api/v1/model_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ type ModelSpec struct {
// Resources are the compute resources required by the container.
Resources *Resources `json:"resources,omitempty"`

// BaseModel should be set in order to mount another model to be
// Model should be set in order to mount another model to be
// used for transfer learning.
BaseModel *ObjectRef `json:"baseModel,omitempty"`
Model *ObjectRef `json:"model,omitempty"`
samos123 marked this conversation as resolved.
Show resolved Hide resolved

// Dataset to mount for training.
TrainingDataset *ObjectRef `json:"trainingDataset,omitempty"`
Dataset *ObjectRef `json:"dataset,omitempty"`
samos123 marked this conversation as resolved.
Show resolved Hide resolved

// Parameters are passing into the model training/loading container as environment variables.
// Environment variable name will be `"PARAM_" + uppercase(key)`.
Expand All @@ -42,6 +42,7 @@ func (m *Model) GetParams() map[string]intstr.IntOrString {
func (m *Model) GetBuild() *Build {
return m.Spec.Build
}

func (m *Model) SetBuild(b *Build) {
m.Spec.Build = b
}
Expand Down
8 changes: 8 additions & 0 deletions api/v1/notebook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (n *Notebook) GetParams() map[string]intstr.IntOrString {
func (n *Notebook) GetBuild() *Build {
return n.Spec.Build
}

func (n *Notebook) SetBuild(b *Build) {
n.Spec.Build = b
}
Expand Down Expand Up @@ -79,6 +80,10 @@ func (n *Notebook) GetStatusUpload() UploadStatus {
return n.Status.BuildUpload
}

func (n *Notebook) GetStatusArtifacts() ArtifactsStatus {
return n.Status.Artifacts
}

func (n *Notebook) IsSuspended() bool {
return n.Spec.Suspend != nil && *n.Spec.Suspend
}
Expand All @@ -92,6 +97,9 @@ type NotebookStatus struct {
// Conditions is the list of conditions that describe the current state of the Notebook.
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Artifacts status.
Artifacts ArtifactsStatus `json:"artifacts,omitempty"`

// BuildUpload contains the status of the build context upload.
BuildUpload UploadStatus `json:"buildUpload,omitempty"`
}
Expand Down
9 changes: 5 additions & 4 deletions api/v1/zz_generated.deepcopy.go

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

8 changes: 2 additions & 6 deletions cmd/controllermanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import (
"io/ioutil"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"gopkg.in/yaml.v2"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand All @@ -26,7 +23,6 @@ import (
"github.com/substratusai/substratus/internal/cloud"
"github.com/substratusai/substratus/internal/controller"
"github.com/substratusai/substratus/internal/sci"
//+kubebuilder:scaffold:imports
)

var (
Expand Down
16 changes: 16 additions & 0 deletions cmd/sub/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"log"

"github.com/substratusai/substratus/internal/cli"
)

var Version = "development"

func main() {
cli.Version = Version
if err := cli.Command().Execute(); err != nil {
log.Fatal(err)
}
}
38 changes: 19 additions & 19 deletions config/crd/bases/substratus.ai_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ spec:
spec:
description: Spec is the desired state of the Model.
properties:
baseModel:
description: BaseModel should be set in order to mount another model
to be used for transfer learning.
properties:
name:
description: Name of Kubernetes object.
type: string
required:
- name
type: object
build:
description: Build specifies how to build an image.
properties:
Expand Down Expand Up @@ -113,6 +103,15 @@ spec:
items:
type: string
type: array
dataset:
description: Dataset to mount for training.
properties:
name:
description: Name of Kubernetes object.
type: string
required:
- name
type: object
env:
additionalProperties:
type: string
Expand All @@ -121,6 +120,16 @@ spec:
image:
description: Image that contains model code and dependencies.
type: string
model:
description: Model should be set in order to mount another model to
be used for transfer learning.
properties:
name:
description: Name of Kubernetes object.
type: string
required:
- name
type: object
params:
additionalProperties:
anyOf:
Expand Down Expand Up @@ -161,15 +170,6 @@ spec:
format: int64
type: integer
type: object
trainingDataset:
description: Dataset to mount for training.
properties:
name:
description: Name of Kubernetes object.
type: string
required:
- name
type: object
type: object
status:
description: Status is the observed state of the Model.
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/substratus.ai_notebooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ spec:
status:
description: Status is the observed state of the Notebook.
properties:
artifacts:
description: Artifacts status.
properties:
url:
type: string
type: object
buildUpload:
description: BuildUpload contains the status of the build context
upload.
Expand Down
36 changes: 31 additions & 5 deletions containertools/cmd/nbwatch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
"path/filepath"
"strings"

"k8s.io/klog/v2"

"github.com/fsnotify/fsnotify"
)

var Version = "development"

func main() {
log.SetOutput(os.Stderr)
log.Println("Starting")

if len(os.Args) == 2 && os.Args[1] == "version" {
fmt.Printf("nbwatch %s\n", Version)
os.Exit(0)
Expand All @@ -33,7 +34,31 @@ func run() error {
}
defer w.Close()

w.Add("/content/src")
const contentDir = "/content"

// NOTE: Watch is non-recursive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it would watch /content/src but not /content/src/my-dir/sam.ipynb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

log.Printf("Watching: %v", contentDir)
w.Add(contentDir)

entries, err := os.ReadDir(contentDir)
if err != nil {
return fmt.Errorf("reading dir: %w", err)
}
for _, e := range entries {
if !e.IsDir() {
continue
}

switch name := e.Name(); name {
case "data", "model", "artifacts":
default:
if !strings.HasPrefix(name, ".") {
p := filepath.Join(contentDir, name)
log.Printf("Watching: %v", p)
w.Add(p)
}
}
}

watchLoop(w)

Expand All @@ -49,7 +74,7 @@ func watchLoop(w *fsnotify.Watcher) {
if !ok { // Channel was closed (i.e. Watcher.Close() was called).
return
}
klog.Error(err)
log.Printf("error: %v", err)
// Read from Events.
case e, ok := <-w.Events:
if !ok { // Channel was closed (i.e. Watcher.Close() was called).
Expand All @@ -59,9 +84,10 @@ func watchLoop(w *fsnotify.Watcher) {
i++
path := e.Name

base := filepath.Base(path)
// Covers ".git", ".gitignore", ".gitmodules", ".gitattributes", ".ipynb_checkpoints"
// and also temporary files that Jupyter writes on save like: ".~hello.py"
if strings.HasPrefix(filepath.Base(path), ".") {
if strings.HasPrefix(base, ".") {
continue
}

Expand Down
Loading
Loading