Skip to content

DATA-3918 Data pipelines CLI commands #4906

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

Merged
merged 41 commits into from
Apr 22, 2025
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7ac07a7
viam datapipelines list
n0nick Apr 9, 2025
dd56a19
viam datapipelines create
n0nick Apr 9, 2025
8de0e92
mql-file
n0nick Apr 9, 2025
804ad71
viam datapipelines update
n0nick Apr 9, 2025
dd00e5c
required=true for some flags
n0nick Apr 10, 2025
4292f71
update fields are optional
n0nick Apr 10, 2025
c18be02
delete
n0nick Apr 10, 2025
021a6c1
.
n0nick Apr 10, 2025
488684e
MQL parsing helper
n0nick Apr 10, 2025
4f66328
describe
n0nick Apr 10, 2025
bb326cd
oops didn't mean to commit mql.json
n0nick Apr 10, 2025
6d5dab3
mql parsing warning
n0nick Apr 10, 2025
95d4913
test ParseMQL
n0nick Apr 10, 2025
a35177d
test mql->json
n0nick Apr 10, 2025
c1cecfb
schedule not time window
n0nick Apr 10, 2025
ee42e0a
print last execution status
n0nick Apr 11, 2025
adc0120
lenient JSON keys
n0nick Apr 11, 2025
9769213
better bson comparison tests
n0nick Apr 11, 2025
2f8daf7
enable, disable
n0nick Apr 11, 2025
e672947
oops didn't mean to commit mql.json
n0nick Apr 11, 2025
4f8f82f
yosuke-furukawa/json5 is bsd
n0nick Apr 11, 2025
760e80c
reorder describe + exported func comments
n0nick Apr 11, 2025
dcdf14a
nolint os.Readfile
n0nick Apr 11, 2025
bc07687
lint long line
n0nick Apr 11, 2025
eb76c20
Merge branch 'main' into sm/pip-cli
n0nick Apr 15, 2025
a27534e
generalFlagID, generalFlagName
n0nick Apr 15, 2025
42facd4
nicer error msg
n0nick Apr 15, 2025
368d323
describe print data range and end time
n0nick Apr 15, 2025
021c0cb
move mql+mqlFile check out
n0nick Apr 15, 2025
c4772e5
MQL parsing error msg
n0nick Apr 15, 2025
3c0a0fd
couple more mql parsing test cases
n0nick Apr 15, 2025
6d69ecd
s/mql-file/mql-path
n0nick Apr 15, 2025
2d6434b
mqlPath
n0nick Apr 15, 2025
eb29e79
list enabled state
n0nick Apr 15, 2025
332fc6b
add some fancy json5 stuff to the example
n0nick Apr 17, 2025
19f5ced
mql path arg name fix oops
n0nick Apr 17, 2025
cba919a
Merge branch 'main' into sm/pip-cli
n0nick Apr 17, 2025
62ba98f
Merge branch 'main' into sm/pip-cli
n0nick Apr 21, 2025
50fa205
updated ListDataPipelineRuns name
n0nick Apr 21, 2025
736d558
cleanup
n0nick Apr 21, 2025
1742991
Merge branch 'main' into sm/pip-cli
n0nick Apr 21, 2025
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
160 changes: 154 additions & 6 deletions cli/app.go
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ const (
generalFlagPart = "part"
generalFlagPartName = "part-name"
generalFlagPartID = "part-id"
generalFlagID = "id"
generalFlagName = "name"
generalFlagMethod = "method"
generalFlagDestination = "destination"
@@ -74,7 +75,6 @@ const (
moduleFlagLocal = "local"
moduleFlagHomeDir = "home"
moduleCreateLocalOnly = "local-only"
moduleFlagID = "id"
moduleFlagIsPublic = "public"
moduleFlagResourceType = "resource-type"
moduleFlagModelName = "model-name"
@@ -117,6 +117,10 @@ const (
dataFlagFilterTags = "filter-tags"
dataFlagTimeout = "timeout"

datapipelineFlagSchedule = "schedule"
datapipelineFlagMQL = "mql"
datapipelineFlagMQLFile = "mql-path"

packageFlagFramework = "model-framework"

oauthAppFlagClientID = "client-id"
@@ -1508,6 +1512,150 @@ var app = &cli.App{
},
},
},
{
Name: "datapipelines",
Usage: "manage and track data pipelines",
UsageText: createUsageText("datapipelines", nil, false, true),
HideHelpCommand: true,
Subcommands: []*cli.Command{
{
Name: "list",
Usage: "list data pipelines for an organization ID",
UsageText: createUsageText("datapipelines list",
[]string{generalFlagOrgID}, true, false),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagOrgID,
Usage: "organization ID for which data pipelines will be listed",
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Description says "org ID". Usage says "organization ID"

Required: true,
},
},
Action: createCommandWithT[datapipelineListArgs](DatapipelineListAction),
},
{
Name: "describe",
Usage: "describe a data pipeline and its status",
UsageText: createUsageText("datapipelines describe", []string{generalFlagID}, true, false),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagID,
Usage: "ID of the data pipeline to describe",
Required: true,
},
},
Action: createCommandWithT[datapipelineDescribeArgs](DatapipelineDescribeAction),
},
{
Name: "create",
Usage: "create a new data pipeline",
UsageText: createUsageText("datapipelines create",
[]string{generalFlagOrgID, generalFlagName, datapipelineFlagSchedule}, false, false,
fmt.Sprintf("[--%s=<%s> | --%s=<%s>]",
datapipelineFlagMQL, datapipelineFlagMQL,
datapipelineFlagMQLFile, datapipelineFlagMQLFile),
),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagOrgID,
Usage: "organization ID for which data pipeline will be created",
Required: true,
},
&cli.StringFlag{
Name: generalFlagName,
Usage: "name of the new data pipeline",
Required: true,
},
&cli.StringFlag{
Name: datapipelineFlagSchedule,
Usage: "schedule of the new data pipeline (cron expression)",
Required: true,
},
&cli.StringFlag{
Name: datapipelineFlagMQL,
Usage: "MQL query for the new data pipeline",
},
&cli.StringFlag{
Name: datapipelineFlagMQLFile,
Usage: "path to JSON file containing MQL query for the new data pipeline",
},
},
Action: createCommandWithT[datapipelineCreateArgs](DatapipelineCreateAction),
},
{
Name: "update",
Usage: "update a data pipeline",
UsageText: createUsageText("datapipelines update",
[]string{generalFlagID, generalFlagName, datapipelineFlagSchedule}, false, false,
fmt.Sprintf("[--%s=<%s> | --%s=<%s>]",
datapipelineFlagMQL, datapipelineFlagMQL,
datapipelineFlagMQLFile, datapipelineFlagMQLFile),
),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagID,
Usage: "ID of the data pipeline to update",
Required: true,
},
&cli.StringFlag{
Name: generalFlagName,
Usage: "name of the data pipeline to update",
},
&cli.StringFlag{
Name: datapipelineFlagSchedule,
Usage: "schedule of the data pipeline to update (cron expression)",
},
&cli.StringFlag{
Name: datapipelineFlagMQL,
Usage: "MQL query for the data pipeline to update",
},
&cli.StringFlag{
Name: datapipelineFlagMQLFile,
Usage: "path to JSON file containing MQL query for the data pipeline to update",
},
},
Action: createCommandWithT[datapipelineUpdateArgs](DatapipelineUpdateAction),
},
{
Name: "delete",
Usage: "delete a data pipeline",
UsageText: createUsageText("datapipelines delete", []string{generalFlagID}, true, false),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagID,
Usage: "ID of the data pipeline to delete",
Required: true,
},
},
Action: createCommandWithT[datapipelineDeleteArgs](DatapipelineDeleteAction),
},
{
Name: "enable",
Usage: "enable a data pipeline",
UsageText: createUsageText("datapipelines enable", []string{generalFlagID}, true, false),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagID,
Usage: "ID of the data pipeline to enable",
Required: true,
},
},
Action: createCommandWithT[datapipelineEnableArgs](DatapipelineEnableAction),
},
{
Name: "disable",
Usage: "disable a data pipeline",
UsageText: createUsageText("datapipelines disable", []string{generalFlagID}, true, false),
Flags: []cli.Flag{
&cli.StringFlag{
Name: generalFlagID,
Usage: "ID of the data pipeline to disable",
Required: true,
},
},
Action: createCommandWithT[datapipelineDisableArgs](DatapipelineDisableAction),
},
},
},
{
Name: "train",
Usage: "train on data",
@@ -2550,7 +2698,7 @@ Example:
DefaultText: "all",
},
&cli.StringFlag{
Name: moduleFlagID,
Name: generalFlagID,
Usage: "restrict output to just return builds that match this id",
},
},
@@ -2560,10 +2708,10 @@ Example:
Name: "logs",
Aliases: []string{"log"},
Usage: "get the logs from one of your cloud builds",
UsageText: createUsageText("module build logs", []string{moduleFlagID}, true, false),
UsageText: createUsageText("module build logs", []string{generalFlagID}, true, false),
Flags: []cli.Flag{
&cli.StringFlag{
Name: moduleFlagID,
Name: generalFlagID,
Usage: "build that you want to get the logs for",
Required: true,
},
@@ -2645,7 +2793,7 @@ This won't work unless you have an existing installation of our GitHub app on yo
Usage: "name of module to restart. pass at most one of --name, --id",
},
&cli.StringFlag{
Name: moduleFlagID,
Name: generalFlagID,
Usage: "ID of module to restart, for example viam:wifi-sensor. pass at most one of --name, --id",
},
&cli.BoolFlag{
@@ -2679,7 +2827,7 @@ This won't work unless you have an existing installation of our GitHub app on yo
Value: ".",
},
&cli.StringFlag{
Name: moduleFlagID,
Name: generalFlagID,
Usage: "module ID as org-id:name or namespace:name",
DefaultText: "will try to read from meta.json",
},
2 changes: 2 additions & 0 deletions cli/auth.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import (
"go.uber.org/multierr"
buildpb "go.viam.com/api/app/build/v1"
datapb "go.viam.com/api/app/data/v1"
datapipelinespb "go.viam.com/api/app/datapipelines/v1"
datasetpb "go.viam.com/api/app/dataset/v1"
mlinferencepb "go.viam.com/api/app/mlinference/v1"
mltrainingpb "go.viam.com/api/app/mltraining/v1"
@@ -528,6 +529,7 @@ func (c *viamClient) ensureLoggedInInner() error {
c.dataClient = datapb.NewDataServiceClient(conn)
c.packageClient = packagepb.NewPackageServiceClient(conn)
c.datasetClient = datasetpb.NewDatasetServiceClient(conn)
c.datapipelinesClient = datapipelinespb.NewDataPipelinesServiceClient(conn)
c.mlTrainingClient = mltrainingpb.NewMLTrainingServiceClient(conn)
c.mlInferenceClient = mlinferencepb.NewMLInferenceServiceClient(conn)
c.buildClient = buildpb.NewBuildServiceClient(conn)
24 changes: 13 additions & 11 deletions cli/client.go
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ import (
"go.uber.org/zap"
buildpb "go.viam.com/api/app/build/v1"
datapb "go.viam.com/api/app/data/v1"
datapipelinespb "go.viam.com/api/app/datapipelines/v1"
datasetpb "go.viam.com/api/app/dataset/v1"
mlinferencepb "go.viam.com/api/app/mlinference/v1"
mltrainingpb "go.viam.com/api/app/mltraining/v1"
@@ -79,17 +80,18 @@ var errNoShellService = errors.New("shell service is not enabled on this machine
// viamClient wraps a cli.Context and provides all the CLI command functionality
// needed to talk to the app and data services but not directly to robot parts.
type viamClient struct {
c *cli.Context
conf *Config
client apppb.AppServiceClient
dataClient datapb.DataServiceClient
packageClient packagepb.PackageServiceClient
datasetClient datasetpb.DatasetServiceClient
mlTrainingClient mltrainingpb.MLTrainingServiceClient
mlInferenceClient mlinferencepb.MLInferenceServiceClient
buildClient buildpb.BuildServiceClient
baseURL *url.URL
authFlow *authFlow
c *cli.Context
conf *Config
client apppb.AppServiceClient
dataClient datapb.DataServiceClient
packageClient packagepb.PackageServiceClient
datasetClient datasetpb.DatasetServiceClient
datapipelinesClient datapipelinespb.DataPipelinesServiceClient
mlTrainingClient mltrainingpb.MLTrainingServiceClient
mlInferenceClient mlinferencepb.MLInferenceServiceClient
buildClient buildpb.BuildServiceClient
baseURL *url.URL
authFlow *authFlow

selectedOrg *apppb.Organization
selectedLoc *apppb.Location
Loading