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

Use new rrq offload configuration API. #34

Merged
merged 4 commits into from
Nov 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: daedalus.api
Title: Serve the 'daedalus' model via an API
Version: 0.1.0
Version: 0.1.1
Authors@R: c(
person("Pratik", "Gupte", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5294-7819")),
Expand All @@ -21,7 +21,7 @@ Imports:
porcelain,
R6,
redux,
rrq,
rrq (>= 0.7.21),
stringr,
tidyr
Suggests:
Expand Down
9 changes: 1 addition & 8 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@ main <- function(args = commandArgs(TRUE)) {
main_worker <- function() {
worker <- rrq::rrq_worker$new(
get_queue_id(),
offload_path = get_results_dir(),
con = get_redis_connection()
)
worker$loop()
}

main_configure_queue <- function() {
queue_id <- get_queue_id()
rrq::rrq_configure(queue_id,
store_max_size = 1000L,
offload_path = get_results_dir(),
con = get_redis_connection())
}
17 changes: 12 additions & 5 deletions R/queue.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ Queue <- R6::R6Class("Queue", # nolint
logs_dir <- get_logs_dir()
results_dir <- get_results_dir()

# Configure rrq to store data > 1KB to disk
offload_threshold_size <- 1000L

# Connect to Redis
con <- get_redis_connection()

# Configure rrq to store data > 1KB to disk
# Create queue
queue_id <- get_queue_id()
# TODO: Check that the queue is configured, when rrq api is available # nolint
self$controller <- rrq::rrq_controller(
queue_id,
offload_threshold_size = offload_threshold_size,
offload_path = results_dir,
con = con)

# Create queue
self$controller <- rrq::rrq_controller(queue_id, con = con)
dir.create(logs_dir, showWarnings = FALSE)
dir.create(results_dir, showWarnings = FALSE)
worker_config <- rrq::rrq_worker_config(logdir = logs_dir)
worker_config <- rrq::rrq_worker_config(
offload_threshold_size = offload_threshold_size,
logdir = logs_dir)
rrq::rrq_worker_config_save("localhost",
worker_config,
controller = self$controller)
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ COPY . /src
RUN R CMD INSTALL --install-tests /src && \
cp /src/docker/daedalus.api /usr/local/bin && \
cp /src/docker/daedalus.api.worker /usr/local/bin && \
cp /src/docker/daedalus.api.configure /usr/local/bin && \
rm -rf /src

# ENTRYPOINT for api is "/usr/local/bin/daedalus.api"
Expand Down
2 changes: 0 additions & 2 deletions docker/daedalus.api.configure

This file was deleted.

9 changes: 1 addition & 8 deletions docker/run_containers
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ docker run --rm -d \
--network=$NAME_NETWORK \
redis

docker run --rm \
--network=$NAME_NETWORK \
--env=DAEDALUS_QUEUE_ID=$QUEUE_ID \
--env=REDIS_CONTAINER_NAME=$NAME_REDIS \
--entrypoint="/usr/local/bin/daedalus.api.configure" \
$TAG_SHA

docker run --rm -d \
-p 8001:8001 \
--name=$NAME_SERVER \
Expand All @@ -38,4 +31,4 @@ docker run --rm -d \
--env=DAEDALUS_QUEUE_ID=$QUEUE_ID \
--env=REDIS_CONTAINER_NAME=$NAME_REDIS\
--entrypoint="/usr/local/bin/daedalus.api.worker" \
$TAG_SHA
$TAG_SHA
3 changes: 2 additions & 1 deletion tests/testthat/helper-daedalus-api.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ check_for_redis <- function() {

start_test_queue_with_worker <- function() {
queue <- Queue$new() # nolint
rrq::rrq_worker_spawn(1L, controller = queue$controller)
rrq::rrq_worker_spawn(1L, controller = queue$controller,
offload_path = get_results_dir())
queue
}

Expand Down