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

Method acquire

misc/python/materialize/mzbuild.py:1377–1424  ·  view source on GitHub ↗

Download or build all of the images in the dependency set that do not already exist locally. Args: max_retries: Number of retries on failure.

(self, max_retries: int | None = None)

Source from the content-addressed store, hash-verified

1375 return pre_image_prep
1376
1377 def acquire(self, max_retries: int | None = None) -> None:
1378 """Download or build all of the images in the dependency set that do not
1379 already exist locally.
1380
1381 Args:
1382 max_retries: Number of retries on failure.
1383 """
1384
1385 # Only retry in CI runs since we struggle with flaky docker pulls there
1386 if not max_retries:
1387 max_retries = (
1388 90
1389 if os.getenv("CI_WAITING_FOR_BUILD")
1390 else (
1391 5
1392 if ui.env_is_truthy("CI")
1393 and not ui.env_is_truthy("CI_ALLOW_LOCAL_BUILD")
1394 else 1
1395 )
1396 )
1397 assert max_retries > 0
1398
1399 deps_to_check = [dep for dep in self if dep.publish]
1400 deps_to_build = [dep for dep in self if not dep.publish]
1401 if len(deps_to_check):
1402 with ThreadPoolExecutor(max_workers=len(deps_to_check)) as executor:
1403 futures = [
1404 executor.submit(dep.try_pull, max_retries) for dep in deps_to_check
1405 ]
1406 for dep, future in zip(deps_to_check, futures):
1407 try:
1408 if not future.result():
1409 deps_to_build.append(dep)
1410 except Exception:
1411 deps_to_build.append(dep)
1412
1413 # Don't attempt to build in CI, as our timeouts and small machines won't allow it anyway
1414 if ui.env_is_truthy("CI") and not ui.env_is_truthy("CI_ALLOW_LOCAL_BUILD"):
1415 expected_deps = [dep for dep in deps_to_build if dep.publish]
1416 if expected_deps:
1417 print(
1418 f"+++ Expected builds to be available, the build probably failed, so not proceeding: {expected_deps}"
1419 )
1420 sys.exit(128)
1421
1422 prep = self._prepare_batch(deps_to_build)
1423 for dep in deps_to_build:
1424 dep.build(prep)
1425
1426 def ensure(self, pre_build: Callable[[list[ResolvedImage]], None] | None = None):
1427 """Ensure all publishable images in this dependency set exist on Docker

Callers 12

shards_usage_auditMethod · 0.80
delete_allMethod · 0.80
write_batchesFunction · 0.80
append_batchesFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
runMethod · 0.80
runMethod · 0.80
overrideMethod · 0.80
_acquire_imageMethod · 0.80
initialize_workerMethod · 0.80

Calls 3

_prepare_batchMethod · 0.95
appendMethod · 0.45
buildMethod · 0.45

Tested by 1

_acquire_imageMethod · 0.64