Skip to content

Commit

Permalink
try dash in service name
Browse files Browse the repository at this point in the history
  • Loading branch information
skyl committed Nov 20, 2024
1 parent 94cd8ad commit 7308b3e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .corpora.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: skyl/corpora
server:
base_url: http://corpora_app:8877
base_url: http://corpora-app:8877
url: https://github.com/skyl/corpora
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Corpora DevContainer",
"dockerComposeFile": "../docker-compose.yaml",
"service": "corpora_interactive",
"service": "corpora-interactive",
"workspaceFolder": "/workspace",
"customizations": {
"vscode": {
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
services:
corpora_app:
corpora-app:
build:
context: .
dockerfile: docker/Dockerfile.app
volumes:
- .:/workspace
environment:
PYTHONPATH: "/workspace/py/packages"
REDIS_URL: "redis://corpora_redis:6379/0"
REDIS_URL: "redis://corpora-redis:6379/0"
OPENAI_API_KEY: "${OPENAI_API_KEY}"
command: python manage.py runserver 0.0.0.0:8877
working_dir: /workspace/py/packages/corpora_proj
depends_on:
- corpora_db
- corpora_redis
- corpora_celery
- corpora-db
- corpora-redis
- corpora-celery
ports:
- "8877:8877"
networks:
- shared-network

corpora_celery:
corpora-celery:
build:
context: .
dockerfile: docker/Dockerfile.app
Expand All @@ -29,15 +29,15 @@ services:
- .:/workspace
environment:
PYTHONPATH: "/workspace/py/packages"
REDIS_URL: "redis://corpora_redis:6379/0"
REDIS_URL: "redis://corpora-redis:6379/0"
OPENAI_API_KEY: "${OPENAI_API_KEY}"
depends_on:
corpora_redis:
corpora-redis:
condition: service_healthy
networks:
- shared-network

corpora_db:
corpora-db:
build:
context: .
dockerfile: docker/Dockerfile.pgvector
Expand All @@ -52,7 +52,7 @@ services:
networks:
- shared-network

corpora_redis:
corpora-redis:
image: redis:latest
ports:
- "6379:6379"
Expand All @@ -64,7 +64,7 @@ services:
networks:
- shared-network

corpora_interactive:
corpora-interactive:
build:
context: .
dockerfile: docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion py/genall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
rm -rf packages/corpora_client
mkdir -p packages/corpora_client/docs packages/corpora_client/test
rm -rf gen/corpora_client
openapi-generator-cli generate -i http://corpora_app:8877/api/openapi.json \
openapi-generator-cli generate -i http://corpora-app:8877/api/openapi.json \
-g python -o gen/corpora_client \
--additional-properties=packageName=corpora_client
# --additional-properties=library=asyncio
Expand Down
5 changes: 3 additions & 2 deletions py/packages/corpora_cli/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AuthError(Exception):
class AuthResolver:
def __init__(self, config: Dict[str, Any]):
self.config = config
base_url = config.get("base_url", "http://corpora_app:8877")
base_url = config.get("base_url", "http://corpora-app:8877")
self.token_url = f"{base_url}/o/token/"

def resolve_auth(self) -> str:
Expand Down Expand Up @@ -100,6 +100,7 @@ def _request_token_with_basic_auth(self, credential: str) -> str:
}
data = {"grant_type": "client_credentials"}

response = requests.post(self.token_url, headers=headers, data=data, timeout=10)
response = requests.post(
self.token_url, headers=headers, data=data, timeout=10)
response.raise_for_status()
return response.json().get("access_token")
2 changes: 1 addition & 1 deletion py/packages/corpora_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_api_clients(
client_config = corpora_client.Configuration()
# TODO: deploy and default to the main production server?
client_config.host = config.get("server", {}).get(
"base_url", "http://corpora_app:8877"
"base_url", "http://corpora-app:8877"
)
client_config.access_token = auth_token
return (
Expand Down
10 changes: 5 additions & 5 deletions py/packages/corpora_cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def yaml_content():
"""Sample YAML content for testing."""
return """
server:
base_url: "http://corpora_app:8877"
base_url: "http://corpora-app:8877"
auth:
client_id: "${CORPORA_CLIENT_ID}"
client_secret: "${CORPORA_CLIENT_SECRET}"
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_load_config_success(mock_yaml_load, mock_file_open, yaml_content, mocke
"""Test load_config with successful loading and env substitution."""
# Set up mock for yaml.safe_load to return the parsed YAML structure
mock_yaml_load.return_value = {
"server": {"base_url": "http://corpora_app:8877"},
"server": {"base_url": "http://corpora-app:8877"},
"auth": {
"client_id": "${CORPORA_CLIENT_ID}",
"client_secret": "${CORPORA_CLIENT_SECRET}",
Expand All @@ -60,7 +60,7 @@ def test_load_config_success(mock_yaml_load, mock_file_open, yaml_content, mocke
assert config["auth"]["client_id"] == "test_client_id"
assert config["auth"]["client_secret"] == "test_client_secret"
assert config["auth"]["optional_auth"] == "optional_auth_value"
assert config["server"]["base_url"] == "http://corpora_app:8877"
assert config["server"]["base_url"] == "http://corpora-app:8877"


@patch("builtins.open", new_callable=mock_open)
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_substitute_env_variables(mocked_env):
"client_secret": "${CORPORA_CLIENT_SECRET}",
"nonexistent_var": "${NON_EXISTENT_VAR}",
},
"server": {"base_url": "http://corpora_app:8877"},
"server": {"base_url": "http://corpora-app:8877"},
}
substituted_config = substitute_env_variables(config)

Expand All @@ -113,4 +113,4 @@ def test_substitute_env_variables(mocked_env):
assert (
substituted_config["auth"]["nonexistent_var"] == ""
) # Non-existent vars default to ""
assert substituted_config["server"]["base_url"] == "http://corpora_app:8877"
assert substituted_config["server"]["base_url"] == "http://corpora-app:8877"
8 changes: 4 additions & 4 deletions py/packages/corpora_proj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"host.docker.internal",
"127.0.0.1",
"localhost",
"corpora_app",
"corpora-app",
]

INSTALLED_APPS = [
Expand Down Expand Up @@ -84,7 +84,7 @@
"USER": os.environ.get("POSTGRES_USER", "postgres"),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", "postgres"),
# db is from the docker compose service name
"HOST": os.environ.get("POSTGRES_HOST", "corpora_db"),
"HOST": os.environ.get("POSTGRES_HOST", "corpora-db"),
"PORT": os.environ.get("POSTGRES_PORT", "5432"),
# not usable with async
# "ATOMIC_REQUESTS": True,
Expand Down Expand Up @@ -133,5 +133,5 @@
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

# Celery settings
CELERY_BROKER_URL = os.getenv("REDIS_URL", "redis://corpora_redis:6379/0")
CELERY_RESULT_BACKEND = os.getenv("REDIS_URL", "redis://corpora_redis:6379/0")
CELERY_BROKER_URL = os.getenv("REDIS_URL", "redis://corpora-redis:6379/0")
CELERY_RESULT_BACKEND = os.getenv("REDIS_URL", "redis://corpora-redis:6379/0")
2 changes: 1 addition & 1 deletion rs/genall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e # Exit on any error

# Define constants
SPEC_URL="http://corpora_app:8877/api/openapi.json"
SPEC_URL="http://corpora-app:8877/api/openapi.json"
OUTPUT_DIR="core/corpora_client"
TEMP_DIR="gen"

Expand Down

0 comments on commit 7308b3e

Please sign in to comment.