Skip to content

Commit

Permalink
Add structure to project and global calibanconfig schema (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Ritchie authored Jul 24, 2020
1 parent 33a9d0b commit 0bd5667
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions caliban/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,34 @@ def expand_image(image: str) -> str:
""""base_image" entry must be a string OR dict with 'cpu' and 'gpu' keys, not '{}'"""
)

CalibanConfig = s.Schema({
s.Optional("build_time_credentials", default=False): bool,
s.Optional("default_mode", default=JobMode.CPU): s.Use(JobMode.parse),
GCloudConfig = {
s.Optional("project_id"): s.And(str, len),
s.Optional("cloud_key"): s.And(str, len),
s.Optional("base_image", default=None): BaseImage,
s.Optional("apt_packages", default=AptPackages.validate({})): AptPackages
})
s.Optional("cloud_key"): s.And(str, len)
}

# Config items that are project-specific, and don't belong in a global
# .calibanconfig shared between projects.
ProjectConfig = {
s.Optional("build_time_credentials", default=False):
bool,
s.Optional("base_image", default=None):
BaseImage,
s.Optional("apt_packages", default=AptPackages.validate({})):
AptPackages,
# If present, Caliban will attempt to install Julia into the base container.
s.Optional("julia_version", default=None):
s.And(str, s.Use(lambda s: s.strip())),
}

# Elements of calibanconfig that are fair game to share between projects.
#
SystemConfig = {
s.Optional("default_mode", default=JobMode.CPU): s.Use(JobMode.parse),
s.Optional("gcloud", default={}): GCloudConfig,
}

# The final, parsed calibanconfig.
CalibanConfig = s.Schema({**ProjectConfig, **SystemConfig})

# Accessors

Expand Down

0 comments on commit 0bd5667

Please sign in to comment.