Skip to content

Commit

Permalink
Rename configs and change logic
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgianaElena committed Apr 7, 2023
1 parent 7d45fe7 commit 17a5b84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions binderhub/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def _template_path_default(self):
help="Origin to use when emitting events. Defaults to hostname of request when empty",
)

no_launch = Bool(
require_build_only = Bool(
False,
help="When enabled, the hub will no longer launch the image after the build",
config=True,
Expand Down Expand Up @@ -930,7 +930,7 @@ def initialize(self, *args, **kwargs):
"auth_enabled": self.auth_enabled,
"event_log": self.event_log,
"normalized_origin": self.normalized_origin,
"no_launch": self.no_launch,
"require_build_only": self.require_build_only,
}
)
if self.auth_enabled:
Expand Down
28 changes: 19 additions & 9 deletions binderhub/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,27 @@ async def get(self, provider_prefix, _unescaped_spec):
else:
image_found = True

no_launch = self.settings.get("no_launch", False)
no_launch_req_query_attr = self.get_query_argument(name="no-launch", default="")
# The request query attribute takes precedence over the traitlet config
if no_launch_req_query_attr:
no_launch = True
if no_launch:
require_build_only = self.settings.get("require_build_only", False)
build_only = False
if not require_build_only:
build_only_query_parameter = self.get_query_argument(name="build_only", default="")
if build_only_query_parameter.lower() == "true":
raise ValueError("Building but not launching is not permitted!")
else:
# Not setting a default will make the function raise an error
# if the `build_only` query parameter is missing from the request
build_only_query_parameter = self.get_query_argument(name="build_only")
if build_only_query_parameter.lower() != "true":
raise ValueError("The `build_only=true` query parameter is required!")
# If we're here, it means a build only deployment is required
build_only = True

if build_only:
await self.emit(
{
"phase": "info",
"imageName": image_name,
"message": "Found no launch option. Image will not be launched after build.\n",
"message": "Build only was enabled. Image will not be launched after build.\n",
}
)
if image_found:
Expand All @@ -430,7 +440,7 @@ async def get(self, provider_prefix, _unescaped_spec):
}
)
with LAUNCHES_INPROGRESS.track_inprogress():
if no_launch:
if build_only:
await self.emit(
{
"phase": "ready",
Expand Down Expand Up @@ -566,7 +576,7 @@ def _check_result(future):
)
BUILD_COUNT.labels(status="success", **self.repo_metric_labels).inc()
with LAUNCHES_INPROGRESS.track_inprogress():
if no_launch:
if build_only:
await self.emit(
{
"phase": "ready",
Expand Down

0 comments on commit 17a5b84

Please sign in to comment.