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

Function setup

misc/python/materialize/scratch.py:497–571  ·  view source on GitHub ↗
(
    i: Instance,
    git_rev: str,
)

Source from the content-addressed store, hash-verified

495
496
497async def setup(
498 i: Instance,
499 git_rev: str,
500) -> None:
501 def is_ready(i: Instance) -> bool:
502 return bool(
503 i.public_ip_address and i.state and i.state.get("Name") == "running"
504 )
505
506 done = False
507 async for remaining in ui.async_timeout_loop(60, 2):
508 print(
509 f"\rscratch> Waiting for instance to become ready: {remaining:0.0f}s remaining\033[K",
510 end="",
511 flush=True,
512 file=sys.stderr,
513 )
514 try:
515 i.reload()
516 if is_ready(i):
517 done = True
518 break
519 except ClientError:
520 pass
521 print(file=sys.stderr)
522 if not done:
523 raise RuntimeError(
524 f"Instance {i} did not become ready in a reasonable amount of time"
525 )
526
527 # Wait for SSH to be available
528 done = False
529 async for remaining in ui.async_timeout_loop(120, 2):
530 print(
531 f"\rscratch> Waiting for SSH access: {remaining:0.0f}s remaining\033[K",
532 end="",
533 flush=True,
534 file=sys.stderr,
535 )
536 try:
537 mssh(i, "true", quiet=True)
538 done = True
539 break
540 except CalledProcessError:
541 continue
542 print(file=sys.stderr)
543 if not done:
544 raise RuntimeError(
545 "SSH did not become available in a reasonable amount of time"
546 )
547
548 # Start git clone while provisioning continues
549 say("Cloning repo (provisioning continues in background)...")
550 mkrepo(i, git_rev)
551
552 # Wait for provisioning to finish
553 done = False
554 async for remaining in ui.async_timeout_loop(300, 2):

Callers 3

setup.pyFile · 0.70
setup_allFunction · 0.70
setup.pyFile · 0.50

Calls 4

is_readyFunction · 0.85
msshFunction · 0.85
sayFunction · 0.85
mkrepoFunction · 0.85

Tested by

no test coverage detected