Skip to content

Commit 6d50084

Browse files
Merge pull request #1689 from SciPhi-AI/feature/scale-with-replicas
cleanup scale settings
2 parents a657528 + d675b06 commit 6d50084

File tree

4 files changed

+512
-2
lines changed

4 files changed

+512
-2
lines changed

py/cli/commands/system.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ async def status(ctx):
126126
default="prod",
127127
help="Which dev environment to pull the image from?",
128128
)
129+
@click.option(
130+
"--scale",
131+
default=None,
132+
help="How many instances of the R2R service to run",
133+
)
129134
@click.option(
130135
"--exclude-postgres",
131136
is_flag=True,
@@ -143,6 +148,7 @@ async def serve(
143148
build,
144149
image,
145150
image_env,
151+
scale,
146152
exclude_postgres,
147153
):
148154
"""Start the R2R server."""
@@ -243,6 +249,7 @@ def image_exists(img):
243249
config_name,
244250
config_path,
245251
exclude_postgres,
252+
scale,
246253
)
247254
if (
248255
"pytest" in sys.modules

py/cli/utils/docker_utils.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def run_docker_serve(
134134
config_name: Optional[str] = None,
135135
config_path: Optional[str] = None,
136136
exclude_postgres: bool = False,
137+
scale: Optional[int] = None,
137138
):
138139
check_docker_compose_version()
139140
check_set_docker_env_vars(project_name, exclude_postgres)
@@ -160,6 +161,7 @@ def run_docker_serve(
160161
config_name,
161162
config_path,
162163
exclude_postgres,
164+
scale,
163165
)
164166

165167
click.secho("R2R now runs on port 7272 by default!", fg="yellow")
@@ -321,6 +323,9 @@ def get_compose_files():
321323
compose_files = {
322324
"base": os.path.join(package_dir, "compose.yaml"),
323325
"full": os.path.join(package_dir, "compose.full.yaml"),
326+
"full_scale": os.path.join(
327+
package_dir, "compose.full_with_replicas.yaml"
328+
),
324329
}
325330

326331
for name, path in compose_files.items():
@@ -357,13 +362,18 @@ def build_docker_command(
357362
image,
358363
config_name,
359364
config_path,
360-
exclude_postgres: bool = False,
365+
exclude_postgres,
366+
scale,
361367
):
362368
if not full:
363369
base_command = f"docker compose -f {compose_files['base']}"
364370
else:
365-
base_command = f"docker compose -f {compose_files['full']}"
371+
if not scale:
372+
base_command = f"docker compose -f {compose_files['full']}"
373+
else:
374+
base_command = f"docker compose -f {compose_files['full_scale']}"
366375

376+
print("base_command = ", base_command)
367377
base_command += (
368378
f" --project-name {project_name or ('r2r-full' if full else 'r2r')}"
369379
)
@@ -388,6 +398,8 @@ def build_docker_command(
388398
if not exclude_postgres:
389399
pull_command = f"{base_command} --profile postgres pull"
390400
up_command = f"{base_command} --profile postgres up -d"
401+
if scale:
402+
up_command += f" --scale r2r={scale}"
391403
else:
392404
pull_command = f"{base_command} pull"
393405
up_command = f"{base_command} up -d"

0 commit comments

Comments
 (0)