Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local dev bugs #22

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions server/app/query/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { useState, useRef, FormEvent, useEffect, Fragment } from "react";
import clsx from "clsx";
import { Listbox, Transition, Combobox } from "@headlessui/react";
import { Listbox, Transition, Combobox, Switch } from "@headlessui/react";
import {
CheckIcon,
ChevronUpDownIcon,
Expand Down Expand Up @@ -126,6 +126,7 @@ function IPAForm({
const [commitSpecifier, setCommitSpecifier] = useState<CommitSpecifier>(
CommitSpecifier.BRANCH,
);
const [stallDetectionEnabled, setStallDetectionEnabled] = useState(true);
const disableBranch = commitSpecifier != CommitSpecifier.BRANCH;
const disableCommitHash = commitSpecifier != CommitSpecifier.COMMIT_HASH;
const filteredCommitHashes =
Expand Down Expand Up @@ -242,7 +243,7 @@ function IPAForm({
<label
htmlFor="commit_hash"
className={clsx(
"block text-md font-medium leading-6 text-gray-900 pt-4 pl-[-30px]",
"block text-sm font-medium leading-6 text-gray-900 pt-4 pl-[-30px]",
disableCommitHash && "opacity-25",
)}
>
Expand Down Expand Up @@ -294,7 +295,6 @@ function IPAForm({
Not a valid commit hash.
</p>
)}

<SelectMenu
id="size"
label="Input Size"
Expand All @@ -319,6 +319,34 @@ function IPAForm({
options={["16", "32", "64", "128", "256"]}
defaultValue="64"
/>
<SelectMenu
id="gate_type"
label="Gate Type"
options={["compact", "descriptive"]}
defaultValue="compact"
/>
<div className="items-center pt-4">
<div className="block text-sm font-medium leading-6 text-gray-900">
Stall detection
</div>
<div className="block pt-1 text-sm font-medium leading-6 text-gray-900">
<Switch
checked={stallDetectionEnabled}
onChange={setStallDetectionEnabled}
name="stall_detection"
className={`${
stallDetectionEnabled ? "bg-blue-600" : "bg-gray-200"
} relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`}
>
<span
className={`${
stallDetectionEnabled ? "translate-x-6" : "translate-x-1"
} inline-block h-4 w-4 transform rounded-full bg-white transition-transform`}
/>
</Switch>
</div>
</div>

<button
type="submit"
className={clsx(
Expand Down Expand Up @@ -394,7 +422,7 @@ function PassedStateSelectMenu({
<>
<Listbox.Label
className={clsx(
"block text-sm font-medium leading-6 text-gray-900",
"block pt-4 text-sm font-medium leading-6 text-gray-900",
labelClassName,
disabled && "opacity-25",
)}
Expand All @@ -403,7 +431,7 @@ function PassedStateSelectMenu({
</Listbox.Label>
<div
className={clsx(
"relative mt-2",
"relative",
selectClassName,
disabled && "opacity-25",
)}
Expand Down
9 changes: 5 additions & 4 deletions sidecar/app/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ def __enter__(self):
def signal_handler(self, sig, _frame):
print(f"Handling signal: {sig}")
for process in self.processes:
for child in psutil.Process(process.pid).children(recursive=True):
child.terminate()
print(f"Terminating: {child}")
process.terminate()
if psutil.pid_exists(process.pid):
for child in psutil.Process(process.pid).children(recursive=True):
child.terminate()
print(f"Terminating: {child}")
process.terminate()
print(f"Terminating: {process}")
sys.exit(0)

Expand Down
19 changes: 17 additions & 2 deletions sidecar/app/query/ipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import time
from dataclasses import dataclass, field
from enum import StrEnum
from pathlib import Path
from typing import ClassVar
from urllib.parse import urlunparse
Expand All @@ -17,6 +18,11 @@
from .step import CommandStep, LoggerOutputCommandStep, Status, Step


class GateType(StrEnum):
COMPACT = "compact-gate"
DESCRIPTIVE = "descriptive-gate"


@dataclass(kw_only=True)
class IPAQuery(Query):
paths: Paths
Expand Down Expand Up @@ -155,23 +161,30 @@ def build_command(self) -> LoggerOutputCommand:
class IPAHelperCompileStep(LoggerOutputCommandStep):
manifest_path: Path
target_path: Path
gate_type: GateType
stall_detection: bool
logger: loguru.Logger = field(repr=False)
status: ClassVar[Status] = Status.COMPILING

@classmethod
def build_from_query(cls, query: IPAQuery):
def build_from_query(cls, query: IPAHelperQuery):
manifest_path = query.paths.repo_path / Path("Cargo.toml")
target_path = query.paths.repo_path / Path(f"target-{query.paths.commit_hash}")
gate_type = query.gate_type
stall_detection = query.stall_detection
return cls(
manifest_path=manifest_path,
target_path=target_path,
gate_type=gate_type,
stall_detection=stall_detection,
logger=query.logger,
)

def build_command(self) -> LoggerOutputCommand:
return LoggerOutputCommand(
cmd=f"cargo build --bin helper --manifest-path={self.manifest_path} "
f'--features="web-app real-world-infra compact-gate stall-detection" '
f'--features="web-app real-world-infra {self.gate_type} '
f"{'stall-detection' if self.stall_detection else ''}\" "
f"--no-default-features --target-dir={self.target_path} "
f"--release",
logger=self.logger,
Expand Down Expand Up @@ -383,6 +396,8 @@ def build_command(self) -> LoggerOutputCommand:
@dataclass(kw_only=True)
class IPAHelperQuery(IPAQuery):
port: int
gate_type: GateType
stall_detection: bool

step_classes: ClassVar[list[type[Step]]] = [
IPACloneStep,
Expand Down
6 changes: 5 additions & 1 deletion sidecar/app/routes/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..local_paths import Paths
from ..query.base import Query
from ..query.demo_logger import DemoLoggerQuery
from ..query.ipa import IPACoordinatorQuery, IPAHelperQuery
from ..query.ipa import GateType, IPACoordinatorQuery, IPAHelperQuery
from ..query.step import Status
from ..settings import settings

Expand Down Expand Up @@ -39,6 +39,8 @@ def demo_logger(
def start_ipa_helper(
query_id: str,
commit_hash: Annotated[str, Form()],
gate_type: Annotated[str, Form()],
stall_detection: Annotated[bool, Form()],
background_tasks: BackgroundTasks,
):
role = settings.role
Expand All @@ -53,6 +55,8 @@ def start_ipa_helper(
query = IPAHelperQuery(
paths=paths,
query_id=query_id,
gate_type=GateType[gate_type.upper()],
stall_detection=stall_detection,
port=settings.helper_port,
)
background_tasks.add_task(query.start)
Expand Down
4 changes: 2 additions & 2 deletions sidecar/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def run_helper_sidecar(
default=Path("local_dev/config"),
show_default=True,
)
@click.option("--root_path", type=click_pathlib.Path(), default=Path("."))
@click.option("--root_path", type=click_pathlib.Path(), default=None)
@click.option("--root_domain", type=str, default="ipa-helper.dev")
@click.option("--sidecar_domain", type=str, default="")
@click.option("--helper_port", type=int, default=7430)
Expand Down Expand Up @@ -265,7 +265,7 @@ def run_local_dev(
identity=role,
helper_port=helper_ports[role],
sidecar_port=sidecar_ports[role],
root_path=root_path,
root_path=root_path / Path(f"tmp/sidecar/{role.value}"),
_env=_env,
)
for role in Role
Expand Down
Loading