Documentation
¶
Overview ¶
Package cli is the root of the Go client for interacting with the DeepSquare Grid.
The Terminal User Interface ¶
The TUI can be run by simply running the github.com/deepsquare-io/grid/cli/cmd/dps package. Its implementation is in the github.com/deepsquare-io/grid/cli/tui package and uses the bubbletea framework to build the terminal application.
The Command Line Interface ¶
The CLI can be run by running subcommands defined in the github.com/deepsquare-io/grid/cli/cmd package. Compared to the TUI, the CLI contains all the commands of the DeepSquare Client.
The DeepSquare Client ¶
A DeepSquare client is available in the github.com/deepsquare-io/grid/cli/deepsquare package. It implements all of the features needed to manage jobs, providers, credits and job logs.
Example:
// Parse private key
pk, err := crypto.HexToECDSA(ethHexPK)
if err != nil {
// ...
}
// Initialize client for simple RPCs
client, err := deepsquare.NewClient(ctx, &deepsquare.ClientConfig{
MetaschedulerAddress: common.HexToAddress("0x..."),
RPCEndpoint: "https://testnet.deepsquare.run/rpc", // Optional
SBatchEndpoint: "https://sbatch.deepsquare.run/graphql", // Optional
LoggerEndpoint: "https://grid-logger.deepsquare.run", // Optional
UserPrivateKey: pk, // Optional, but needed for authenticated requests
})
// Example of job submit
curr, err := client.AllowanceManager.GetAllowance(ctx)
if err != nil {
// ...
}
err = client.AllowanceManager.SetAllowance(ctx, curr.Add(curr, lockedAmount))
if err != nil {
// ...
}
jobID, err := client.SubmitJob(ctx, job, lockedAmount, jobName, types.WithAffinity(affinities))
// Initialize client for streaming RPCs
watcher, err := deepsquare.NewWatcher(ctx, &deepsquare.WatcherConfig{
MetaschedulerAddress: common.HexToAddress("0x..."),
RPCEndpoint: "https://testnet.deepsquare.run/rpc", // Optional
WSEndpoint: "https://testnet.deepsquare.run/ws", // Optional
UserPrivateKey: pk, // Optional, but needed for authenticated requests
})
defer watcher.Close()
// Example of watching job transition
transitions := make(chan types.JobTransition, 1)
sub, err := watcher.SubscribeEvents(ctx, event.FilterJobTransition(transitions))
if err != nil {
return err
}
defer sub.Unsubscribe()
See the github.com/deepsquare-io/grid/cli/deepsquare package documentation for more information.
Fine-grained RPC or WebSocket client ¶
If the DeepSquare client is too much "coupled", a more fine-grained client is available in the github.com/deepsquare-io/grid/cli/metascheduler package.
Example:
// Initialize RPC client
ethClientRPC := ethclient.Dial("https://testnet.deepsquare.run/rpc")
chainID, err := ethClientRPC.ChainID(ctx)
if err != nil {
return nil, err
}
rpcBackend := metascheduler.Backend{
EthereumBackend: ethClientRPC,
MetaschedulerAddress: common.HexToAddress("0x..."),
ChainID: chainID,
UserPrivateKey: pk,
}
clientset := metascheduler.NewRPCClientSet(rpcBackend)
// Example of job submit
curr, err := clientset.AllowanceManager().GetAllowance(ctx)
if err != nil {
// ...
}
err = clientset.AllowanceManager().SetAllowance(ctx, curr.Add(curr, lockedAmount))
if err != nil {
// ...
}
sbatch := sbatch.NewService(http.DefaultClient, "https://sbatch.deepsquare.run/graphql")
jobID, err := clientset.JobScheduler(sbatch).SubmitJob(ctx, job, lockedAmount, jobName, types.WithAffinity(affinities))
// Initialize WebSocket client
ethClientWS := ethclient.Dial("https://testnet.deepsquare.run/ws")
defer ethClientWS.Close()
wsBackend := metascheduler.Backend{
MetaschedulerAddress: common.HexToAddress("0x..."),
EthereumBackend: ethClientWS,
ChainID: chainID,
UserPrivateKey: pk,
}
es := metascheduler.NewEventSubscriber(rpcBackend, wsBackend)
// Example of watching job transition
transitions := make(chan types.JobTransition, 1)
sub, err := es.SubscribeEvents(ctx, event.FilterJobTransition(transitions))
if err != nil {
return err
}
defer sub.Unsubscribe()
See the github.com/deepsquare-io/grid/cli/metascheduler package documentation for more information.
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
init
command
|
|
|
jobs
command
|
|
|
submit
command
|
|
|
cmd
|
|
|
allowance
Package allowance provides subcommands to manage the allowance of an user.
|
Package allowance provides subcommands to manage the allowance of an user. |
|
credit
Package credit provides subcommands to manage the credits of an user.
|
Package credit provides subcommands to manage the credits of an user. |
|
dps
command
DeepSquare TUI is a client to launch jobs on the DeepSquare Grid.
|
DeepSquare TUI is a client to launch jobs on the DeepSquare Grid. |
|
initc
Package initc provides subcommands to initialize templates to get started with DeepSquare.
|
Package initc provides subcommands to initialize templates to get started with DeepSquare. |
|
job
Package job provides subcommands to manage the jobs of an user.
|
Package job provides subcommands to manage the jobs of an user. |
|
provider
Package provider provides subcommands to manage the providers of the Grid.
|
Package provider provides subcommands to manage the providers of the Grid. |
|
submit
Package submit permits the submission of a job to the DeepSquare Grid.
|
Package submit permits the submission of a job to the DeepSquare Grid. |
|
validate
Package submit permits the submission of a job to the DeepSquare Grid.
|
Package submit permits the submission of a job to the DeepSquare Grid. |
|
Package deepsquare provides a all-in-one Client that implements all of the DeepSquare services.
|
Package deepsquare provides a all-in-one Client that implements all of the DeepSquare services. |
|
internal
|
|
|
ether
Package ether provides utilities for ether to wei conversions.
|
Package ether provides utilities for ether to wei conversions. |
|
graphql
Package graphql provides wrappers for graphQL API objects.
|
Package graphql provides wrappers for graphQL API objects. |
|
log
Package log initialize the logger for the TUI.
|
Package log initialize the logger for the TUI. |
|
utils
Package utils provides utilities functions.
|
Package utils provides utilities functions. |
|
validator
Package validator providers utilities for user input validation.
|
Package validator providers utilities for user input validation. |
|
wordlists
Package wordlists providers utilities to generate random words.
|
Package wordlists providers utilities to generate random words. |
|
Package logger providers an implementation of the Grid Logger reader.
|
Package logger providers an implementation of the Grid Logger reader. |
|
Package metascheduler defines APIs for interacting with the DeepSquare Grid.
|
Package metascheduler defines APIs for interacting with the DeepSquare Grid. |
|
mocks
|
|
|
Package sbatch provides implementations of the SBatchService client.
|
Package sbatch provides implementations of the SBatchService client. |
|
Package tui implements all the fron-end logic for a Terminal User Interface of the DeepSquare client.
|
Package tui implements all the fron-end logic for a Terminal User Interface of the DeepSquare client. |
|
channel
Package channel provides utilities to create an Bubbletea model compatible with Go channels.
|
Package channel provides utilities to create an Bubbletea model compatible with Go channels. |
|
components/table
Package table is a forked bubbletea component with support single cell styling.
|
Package table is a forked bubbletea component with support single cell styling. |
|
components/ticker
Package ticker contains the Model and Update function to work with a Go Ticker.
|
Package ticker contains the Model and Update function to work with a Go Ticker. |
|
editor
Package editor contains the Model, View and Update functions for the workflow editor.
|
Package editor contains the Model, View and Update functions for the workflow editor. |
|
nav
Package nav contains the Model, View and Update functions for the main navigator.
|
Package nav contains the Model, View and Update functions for the main navigator. |
|
provider
Package provider contains the Model, View and Update functions to manage providers.
|
Package provider contains the Model, View and Update functions to manage providers. |
|
provider/details
Package details contains the Model, View and Update functions for viewing the provider details.
|
Package details contains the Model, View and Update functions for viewing the provider details. |
|
status
Package status contains the Model, View and Update functions for the job statuses dashboard.
|
Package status contains the Model, View and Update functions for the job statuses dashboard. |
|
status/log
Package log contains the Model, View and Update functions for viewing the logs of a job.
|
Package log contains the Model, View and Update functions for viewing the logs of a job. |
|
status/topup
Package topup contains the Model, View and Update functions for submitting a top up request.
|
Package topup contains the Model, View and Update functions for submitting a top up request. |
|
style
Package style provides object for styling the TUI.
|
Package style provides object for styling the TUI. |
|
transfer
Package transfer contains the Model, View and Update functions for transferring credits between users.
|
Package transfer contains the Model, View and Update functions for transferring credits between users. |
|
Package types provides the main types of the library.
|
Package types provides the main types of the library. |
|
allowance
Package allowance describes the types and methods to interact with the
|
Package allowance describes the types and methods to interact with the |
|
credit
Package credit describes the types and methods to interact with the credits.
|
Package credit describes the types and methods to interact with the credits. |
|
event
Package event describes the types and methods to interact with the events.
|
Package event describes the types and methods to interact with the events. |
|
job
Package job describes the types and methods to interact with the jobs.
|
Package job describes the types and methods to interact with the jobs. |
|
provider
Package provider defines the interface for managing providers.
|
Package provider defines the interface for managing providers. |
|
Package version contains functions to track the module version.
|
Package version contains functions to track the module version. |