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

Add Exclusion Flag for Postgres #1328

Merged
merged 1 commit into from
Oct 3, 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
8 changes: 8 additions & 0 deletions py/cli/commands/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ def generate_report():
default="prod",
help="Which dev environment to pull the image from?",
)
@click.option(
"--exclude-postgres",
is_flag=True,
default=False,
help="Excludes creating a Postgres container in the Docker setup.",
)
async def serve(
host,
port,
Expand All @@ -235,6 +241,7 @@ async def serve(
build,
image,
image_env,
exclude_postgres,
):
"""Start the R2R server."""
load_dotenv()
Expand Down Expand Up @@ -334,6 +341,7 @@ def image_exists(img):
image,
config_name,
config_path,
exclude_postgres,
)
if (
"pytest" in sys.modules
Expand Down
29 changes: 20 additions & 9 deletions py/cli/utils/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ def run_docker_serve(
image: str,
config_name: Optional[str] = None,
config_path: Optional[str] = None,
exclude_postgres: bool = False,
):
check_docker_compose_version()
check_set_docker_env_vars()
check_set_docker_env_vars(exclude_postgres)

if config_path and config_name:
raise ValueError("Cannot specify both config_path and config_name")
Expand All @@ -149,6 +150,7 @@ def run_docker_serve(
image,
config_name,
config_path,
exclude_postgres,
)

click.secho("R2R now runs on port 7272 by default!", fg="yellow")
Expand Down Expand Up @@ -238,17 +240,21 @@ def check_external_ollama(ollama_url="http://localhost:11434/api/version"):
sys.exit(1)


def check_set_docker_env_vars():
def check_set_docker_env_vars(exclude_postgres: bool = False):

env_vars = {
"R2R_PROJECT_NAME": "r2r",
"POSTGRES_HOST": "postgres",
"POSTGRES_PORT": "5432",
"POSTGRES_DBNAME": "postgres",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "postgres",
}

if not exclude_postgres:
env_vars |= {
"POSTGRES_HOST": "postgres",
"POSTGRES_PORT": "5432",
"POSTGRES_DBNAME": "postgres",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "postgres",
}

is_test = (
"pytest" in sys.modules
or "unittest" in sys.modules
Expand Down Expand Up @@ -319,6 +325,7 @@ def build_docker_command(
image,
config_name,
config_path,
exclude_postgres: bool = False,
):
if not full:
base_command = f"docker compose -f {compose_files['base']}"
Expand Down Expand Up @@ -346,8 +353,12 @@ def build_docker_command(
elif full:
os.environ["CONFIG_NAME"] = "full"

pull_command = f"{base_command} pull"
up_command = f"{base_command} up -d"
if not exclude_postgres:
pull_command = f"{base_command} --profile postgres pull"
up_command = f"{base_command} --profile postgres up -d"
else:
pull_command = f"{base_command} pull"
up_command = f"{base_command} up -d"

return pull_command, up_command

Expand Down
12 changes: 1 addition & 11 deletions py/compose.full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ volumes:
services:
postgres:
image: pgvector/pgvector:pg16
profiles: [postgres]
environment:
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
Expand Down Expand Up @@ -86,9 +87,6 @@ services:
POSTGRES_HOST: "${POSTGRES_HOST:-postgres}"
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
HATCHET_POSTGRES_DBNAME: "${HATCHET_POSTGRES_DBNAME:-hatchet}"
depends_on:
postgres:
condition: service_healthy
networks:
- r2r-network

Expand All @@ -109,8 +107,6 @@ services:
depends_on:
hatchet-create-db:
condition: service_completed_successfully
postgres:
condition: service_healthy
networks:
- r2r-network

Expand Down Expand Up @@ -147,8 +143,6 @@ services:
condition: service_completed_successfully
hatchet-rabbitmq:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- r2r-network

Expand Down Expand Up @@ -283,8 +277,6 @@ services:
- hatchet_config:/hatchet/config
- hatchet_api_key:/hatchet_api_key
depends_on:
postgres:
condition: service_healthy
hatchet-setup-config:
condition: service_completed_successfully

Expand Down Expand Up @@ -377,8 +369,6 @@ services:
depends_on:
setup-token:
condition: service_completed_successfully
postgres:
condition: service_healthy
unstructured:
condition: service_healthy

Expand Down
4 changes: 1 addition & 3 deletions py/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ networks:
services:
postgres:
image: pgvector/pgvector:pg16
profiles: [postgres]
environment:
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
Expand Down Expand Up @@ -120,9 +121,6 @@ services:
- "traefik.http.middlewares.r2r-headers.headers.customresponseheaders.Access-Control-Expose-Headers=Content-Length,Content-Range"
extra_hosts:
- host.docker.internal:host-gateway
depends_on:
postgres:
condition: service_healthy

r2r-dashboard:
image: emrgntcmplxty/r2r-dashboard:latest
Expand Down
Loading