Skip to content

Commit 276d8bb

Browse files
authored
RSDK-11488 - module reload cli improvements (#5197)
1 parent 18f9b07 commit 276d8bb

File tree

8 files changed

+414
-92
lines changed

8 files changed

+414
-92
lines changed

cli/app.go

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,19 @@ const (
8888
moduleFlagDryRun = "dry-run"
8989
moduleFlagUpload = "upload"
9090

91-
moduleBuildFlagRef = "ref"
92-
moduleBuildFlagWait = "wait"
93-
moduleBuildFlagToken = "token"
94-
moduleBuildFlagWorkdir = "workdir"
95-
moduleBuildFlagPlatforms = "platforms"
96-
moduleBuildFlagGroupLogs = "group-logs"
97-
moduleBuildRestartOnly = "restart-only"
98-
moduleBuildFlagNoBuild = "no-build"
99-
moduleBuildFlagOAuthLink = "oauth-link"
100-
moduleBuildFlagRepo = "repo"
91+
moduleBuildFlagRef = "ref"
92+
moduleBuildFlagWait = "wait"
93+
moduleBuildFlagToken = "token"
94+
moduleBuildFlagWorkdir = "workdir"
95+
moduleBuildFlagPlatforms = "platforms"
96+
moduleBuildFlagGroupLogs = "group-logs"
97+
moduleBuildRestartOnly = "restart-only"
98+
moduleBuildFlagNoBuild = "no-build"
99+
moduleBuildFlagCloudBuild = "cloud-build"
100+
moduleBuildFlagCloudConfig = "cloud-config"
101+
moduleBuildFlagID = "build-id"
102+
moduleBuildFlagOAuthLink = "oauth-link"
103+
moduleBuildFlagRepo = "repo"
101104

102105
mlTrainingFlagName = "script-name"
103106
mlTrainingFlagFramework = "framework"
@@ -2871,10 +2874,13 @@ Example:
28712874
Usage: "get the logs from one of your cloud builds",
28722875
UsageText: createUsageText("module build logs", []string{generalFlagID}, true, false),
28732876
Flags: []cli.Flag{
2874-
&cli.StringFlag{
2875-
Name: generalFlagID,
2876-
Usage: "build that you want to get the logs for",
2877-
Required: true,
2877+
&AliasStringFlag{
2878+
cli.StringFlag{
2879+
Name: moduleBuildFlagID,
2880+
Usage: "build that you want to get the logs for",
2881+
Aliases: []string{generalFlagID},
2882+
Required: true,
2883+
},
28782884
},
28792885
&cli.StringFlag{
28802886
Name: moduleFlagPlatform,
@@ -2929,13 +2935,22 @@ This won't work unless you have an existing installation of our GitHub app on yo
29292935
29302936
# A full reload command. This will build your module, send the tarball to the machine with given part ID,
29312937
# and configure or restart it.
2932-
# The GOARCH env in this case would get passed to an underlying go build (assuming you're targeting an arm device).
2933-
# Note that you'll still need to add the components for your models after your module is installed.
2934-
GOARCH=arm64 viam module reload --part-id UUID
2938+
viam module reload --part-id UUID
29352939
29362940
# Restart a module running on your local viam server, by name, without building or reconfiguring.
29372941
viam module reload --restart-only --id viam:python-example-module
29382942
2943+
# Use cloudbuild to build the tar.gz that will be copied to the part for hot reloading.
2944+
viam module reload --cloud-build
2945+
2946+
# Run viam module reload on a mac and use the downloaded viam.json file instead of --part-id
2947+
viam module reload --cloud-config ~/Downloads/viam-mac-main.json
2948+
2949+
# Specify a component/service model (and optionally a name) to add to the config along with
2950+
# the module (the API is automatically looked up from meta.json)
2951+
# By default, no resources are added when a module is reloaded
2952+
viam module reload --model-name acme:module-name:mybase --name my-resource
2953+
29392954
# Build and configure a module on your local machine without shipping a tarball.
29402955
viam module reload --local`,
29412956
Flags: []cli.Flag{
@@ -2978,6 +2993,35 @@ This won't work unless you have an existing installation of our GitHub app on yo
29782993
Usage: "remote user's home directory. only necessary if you're targeting a remote machine where $HOME is not /root",
29792994
Value: "~",
29802995
},
2996+
&cli.BoolFlag{
2997+
Name: moduleBuildFlagCloudBuild,
2998+
Usage: "Run the module's build script using cloud build instead of locally, downloading to the build.path field in meta.json",
2999+
},
3000+
&cli.PathFlag{
3001+
Name: moduleBuildFlagCloudConfig,
3002+
Usage: "Provide the location of the viam.json file with robot ID to lookup the part-id. Use instead of --part-id option.",
3003+
Value: "/etc/viam.json",
3004+
},
3005+
&cli.StringFlag{
3006+
Name: moduleFlagModelName,
3007+
Usage: "If passed, creates a resource in the part config with the given model triple",
3008+
DefaultText: "Don't create a new resource",
3009+
},
3010+
&cli.StringFlag{
3011+
Name: moduleBuildFlagWorkdir,
3012+
Usage: "use this to indicate that your meta.json is in a subdirectory of your repo. --module flag should be relative to this",
3013+
Value: ".",
3014+
},
3015+
&cli.StringFlag{
3016+
Name: dataFlagResourceName,
3017+
Usage: "Use with model-name to name the newly added resource",
3018+
DefaultText: "resource type with a unique numerical suffix",
3019+
},
3020+
&cli.StringFlag{
3021+
Name: generalFlagPath,
3022+
Usage: "Use this with --cloud-build to indicate the path to the root of the git repo to build",
3023+
DefaultText: ".",
3024+
},
29813025
},
29823026
Action: createCommandWithT[reloadModuleArgs](ReloadModuleAction),
29833027
},

0 commit comments

Comments
 (0)