Skip to content

Commit

Permalink
fix: remove batch_size
Browse files Browse the repository at this point in the history
  • Loading branch information
zietzm committed Aug 29, 2024
1 parent 6ba339a commit 72a1645
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ sqlite_db = "sqlite:///backend.db"
n_workers = 1

[indirect_gwas]
batch_size = 10000
4 changes: 2 additions & 2 deletions src/webgwas_backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from typing import Any

from dynaconf import Dynaconf
from pydantic import BaseModel, Field
from pydantic import BaseModel
from pydantic_settings import BaseSettings


class IndirectGWASSettings(BaseModel):
batch_size: int = Field(10000, description="Batch size (in variants)")
pass


class Settings(BaseSettings):
Expand Down
3 changes: 1 addition & 2 deletions src/webgwas_backend/igwas_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_igwas_coef(request: WebGWASRequestID) -> Series:


def handle_igwas(
request: WebGWASRequestID, dry_run: bool, s3_bucket: str, batch_size: int
request: WebGWASRequestID, dry_run: bool, s3_bucket: str
) -> WebGWASResult:
beta_series = get_igwas_coef(request)
cov_path = pathlib.Path(request.cohort.root_directory).joinpath(
Expand All @@ -69,7 +69,6 @@ def handle_igwas(
gwas_result_path=gwas_path.as_posix(),
output_file_path=output_file_path.as_posix(),
num_covar=request.cohort.num_covar,
batch_size=batch_size,
)
except Exception as e:
raise HTTPException(
Expand Down
2 changes: 1 addition & 1 deletion src/webgwas_backend/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def client():
s3_bucket="TEST",
sqlite_db=":memory:",
n_workers=2,
indirect_gwas=IndirectGWASSettings(batch_size=10000),
indirect_gwas=IndirectGWASSettings(),
)
worker = TestWorker(settings)

Expand Down
13 changes: 3 additions & 10 deletions src/webgwas_backend/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Worker:
def __init__(self, settings: Settings):
self.s3_dry_run = settings.dry_run
self.s3_bucket = settings.s3_bucket
self.batch_size = settings.indirect_gwas.batch_size

self.manager = Manager()
self.lock = self.manager.Lock()
Expand All @@ -30,16 +29,13 @@ def submit(self, request: WebGWASRequestID):
request,
self.s3_dry_run,
self.s3_bucket,
self.batch_size,
)
logger.info(f"Queued request: {request.id}")

@staticmethod
def handle_request(
request: WebGWASRequestID, dry_run: bool, s3_bucket: str, batch_size: int
):
def handle_request(request: WebGWASRequestID, dry_run: bool, s3_bucket: str):
try:
return handle_igwas(request, dry_run, s3_bucket, batch_size)
return handle_igwas(request, dry_run, s3_bucket)
except Exception as e:
return WebGWASResult(
request_id=request.id, status="error", error_msg=f"{e}"
Expand Down Expand Up @@ -67,14 +63,11 @@ class TestWorker(Worker):
def __init__(self, settings: Settings):
self.s3_dry_run = settings.dry_run
self.s3_bucket = settings.s3_bucket
self.batch_size = settings.indirect_gwas.batch_size
self.id_to_result: dict[str, WebGWASResult] = {}

def submit(self, request: WebGWASRequestID):
logger.info(f"Submitting request: {request}")
result = self.handle_request(
request, self.s3_dry_run, self.s3_bucket, self.batch_size
)
result = self.handle_request(request, self.s3_dry_run, self.s3_bucket)
self.id_to_result[request.id] = result
logger.info(f"Queued request: {request.id}")

Expand Down

0 comments on commit 72a1645

Please sign in to comment.