18 from typing
import Any, List, Optional, Union
20 from tabulate
import tabulate
25 from ...node
import NodeMode
26 from ...configuration
import NodeConfiguration
32 type: Optional[Union[type, click.ParamType]] =
None,
36 return click.prompt(click.style(f
"\n\U00002754 {text}", fg =
"cyan"), default = default, type = type, **kwargs)
39 def arrowPrompt(choices: List[Any], message: str) -> Any:
41 answers = inquirer.prompt([
49 return answers[
"option"]
52 def previewNodeConfig(nodeConfig: NodeConfiguration) ->
None:
53 allowDocker =
"Yes" if nodeConfig.allowDocker
else "No"
55 if nodeConfig.secret
is None or nodeConfig.secret ==
"":
58 nodeSecret =
"********"
61 [
"Node name", nodeConfig.name],
62 [
"Node image", nodeConfig.image],
63 [
"Storage path", nodeConfig.storagePath],
64 [
"RAM", f
"{nodeConfig.ram}GB"],
65 [
"SWAP memory", f
"{nodeConfig.swap}GB"],
66 [
"POSIX shared memory", f
"{nodeConfig.sharedMemory}GB"],
67 [
"CPU cores allocated", f
"{nodeConfig.cpuCount}"],
68 [
"Node mode", f
"{NodeMode(nodeConfig.mode).name}"],
69 [
"Docker access", allowDocker],
70 [
"Node secret", nodeSecret],
71 [
"Node init script", nodeConfig.initScript
if nodeConfig.initScript
is not None else ""],
72 [
"Node heartbeat interval", f
"{nodeConfig.heartbeatInterval // 1000}s"]
74 if nodeConfig.modelId
is not None:
75 table.append([
"Coretex Model ID", f
"{nodeConfig.modelId}"])
77 if nodeConfig.nearWalletId
is not None:
78 table.append([
"NEAR wallet id", nodeConfig.nearWalletId])
80 if nodeConfig.endpointInvocationPrice
is not None:
81 table.append([
"Endpoint invocation price", f
"{nodeConfig.endpointInvocationPrice}"])
83 stdEcho(tabulate(table))
86 def outputUrl(baseUrl: str, entityUrl: str) -> str:
87 return (
"\033[4m" + f
"{baseUrl}/{entityUrl}" +
"\033[0m")
90 def stdEcho(text: str) ->
None:
91 click.echo(click.style(f
"\n{text}", fg =
"cyan"))
94 def warningEcho(text: str) ->
None:
95 click.echo(click.style(f
"\nWARNING: {text}", fg =
"yellow"))
98 def successEcho(text: str) ->
None:
99 click.echo(click.style(f
"\n\U0001F680 {text} \U0001F680", fg =
"green"))
102 def progressEcho(text: str) ->
None:
103 click.echo(click.style(f
"\n\U00002699 {text} \U00002699", fg =
"yellow"))
106 def errorEcho(text: str) ->
None:
107 click.echo(click.style(f
"\n\U0000274C {text} \U0000274C", fg =
"red"))
110 def highlightEcho(text: str) ->
None:
111 click.echo(click.style(f
"\n\U00002755 {text} \U00002755"))