MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / run

Function run

misc/python/materialize/cli/scratch/go.py:61–102  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

59
60
61def run(args: argparse.Namespace) -> None:
62 # Read the machine config, applying any overrides.
63 descs = load_machine_descs(
64 args.machine,
65 instance_type=args.instance_type,
66 size_gb=args.size_gb,
67 )
68
69 if len(descs) != 1:
70 raise RuntimeError(
71 f"'go' expects a single-machine config, got {len(descs)} machines"
72 )
73
74 check_required_vars()
75
76 # Try to find an existing instance
77 try:
78 instance = get_instance("mine")
79 say(f"Found existing instance {instance.instance_id} ({name(tags(instance))})")
80 print_instances([instance], "table")
81 print("Connecting...")
82 mssh(instance, "")
83 return
84 except RuntimeError:
85 pass
86
87 # No existing instance — create one
88 label = args.machine or args.instance_type
89 say(f"No existing instance found, creating from {label}...")
90
91 max_age = datetime.timedelta(days=args.max_age_days)
92 extra_tags = {"LaunchedBy": whoami()}
93 instances = launch_cluster(
94 descs,
95 extra_tags=extra_tags,
96 delete_after=datetime.datetime.now(datetime.timezone.utc) + max_age,
97 )
98
99 print("Launched:")
100 print_instances(instances, "table")
101 print("Connecting...")
102 mssh(instances[0], "")

Callers

nothing calls this directly

Calls 11

load_machine_descsFunction · 0.90
check_required_varsFunction · 0.90
get_instanceFunction · 0.90
nameFunction · 0.90
tagsFunction · 0.90
print_instancesFunction · 0.90
msshFunction · 0.90
whoamiFunction · 0.90
launch_clusterFunction · 0.90
sayFunction · 0.85
nowMethod · 0.45

Tested by

no test coverage detected