Skip to content

Commit

Permalink
Merge branch 'master' into table_size
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt authored Dec 13, 2024
2 parents dcff03c + 868187d commit b64de60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
4 changes: 3 additions & 1 deletion agent/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def __init__(
no_cache: bool,
no_push: bool,
registry: dict,
platform: str,
) -> None:
super().__init__()

# Image push params
self.image_repository = image_repository
self.image_tag = image_tag
self.registry = registry
self.platform = platform

# Build context, params
self.filename = filename
Expand Down Expand Up @@ -108,7 +110,7 @@ def _build_image(self):
return {"output": self.output["build"]}

def _get_build_command(self) -> str:
command = "docker buildx build --platform linux/amd64"
command = f"docker buildx build --platform {self.platform}"
command = f"{command} -t {self._get_image_name()}"

if self.no_cache:
Expand Down
27 changes: 22 additions & 5 deletions agent/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def build_image():
no_cache=data.get("no_cache"),
no_push=data.get("no_push"),
registry=data.get("registry"),
platform=data.get("platform", "linux/amd64"),
)
job = image_builder.run_remote_builder()
return {"job": job}
Expand Down Expand Up @@ -550,7 +551,10 @@ def backup_site(bench, site):
return {"job": job}


@application.route("/benches/<string:bench>/sites/<string:site>/database/schema", methods=["POST"])
@application.route(
"/benches/<string:bench>/sites/<string:site>/database/schema",
methods=["POST"],
)
@validate_bench_and_site
def fetch_database_table_schema(bench, site):
data = request.json or {}
Expand All @@ -568,7 +572,10 @@ def fetch_database_table_schema(bench, site):
return {"job": job}


@application.route("/benches/<string:bench>/sites/<string:site>/database/query/execute", methods=["POST"])
@application.route(
"/benches/<string:bench>/sites/<string:site>/database/query/execute",
methods=["POST"],
)
@validate_bench_and_site
def run_sql(bench, site):
query = request.json.get("query")
Expand Down Expand Up @@ -596,6 +603,9 @@ def analyze_slow_queries(bench: str, site: str):


@application.route("/benches/<string:bench>/sites/<string:site>/database/users", methods=["POST"])
"/benches/<string:bench>/sites/<string:site>/database/users",

Check failure on line 606 in agent/web.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff

agent/web.py:606:1: SyntaxError: Expected class, function definition or async function definition after decorator
methods=["POST"],
)

Check failure on line 608 in agent/web.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff

agent/web.py:608:1: SyntaxError: Expected a statement
@validate_bench_and_site

Check failure on line 609 in agent/web.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff

agent/web.py:608:2: SyntaxError: Expected a statement
def create_database_user(bench, site):
data = request.json
Expand All @@ -609,7 +619,8 @@ def create_database_user(bench, site):


@application.route(
"/benches/<string:bench>/sites/<string:site>/database/users/<string:db_user>", methods=["DELETE"]
"/benches/<string:bench>/sites/<string:site>/database/users/<string:db_user>",
methods=["DELETE"],
)
@validate_bench_and_site
def remove_database_user(bench, site, db_user):
Expand All @@ -630,7 +641,10 @@ def update_database_permissions(bench, site, db_user):
.benches[bench]
.sites[site]
.modify_database_user_permissions_job(
db_user, data["mode"], data.get("permissions", {}), data["mariadb_root_password"]
db_user,
data["mode"],
data.get("permissions", {}),
data["mariadb_root_password"],
)
)
return {"job": job}
Expand Down Expand Up @@ -1344,7 +1358,10 @@ def site_not_found(e):

@application.route("/docker_cache_utils/<string:method>", methods=["POST"])
def docker_cache_utils(method: str):
from agent.docker_cache_utils import get_cached_apps, run_command_in_docker_cache
from agent.docker_cache_utils import (
get_cached_apps,
run_command_in_docker_cache,
)

if method == "run_command_in_docker_cache":
return run_command_in_docker_cache(**request.json)
Expand Down

0 comments on commit b64de60

Please sign in to comment.