Skip to content
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
10 changes: 5 additions & 5 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ services:
DB_USER: renku
DB_NAME: renku
DB_PASSWORD: renku
DB_HOST: 127.0.0.1
DB_HOST: 127.0.0.1
CORS_ALLOW_ALL_ORIGINS: "true"
ALEMBIC_CONFIG: /workspace/components/renku_data_services/migrations/alembic.ini
AUTHZ_DB_HOST: 127.0.0.1
AUTHZ_DB_GRPC_PORT: "50051"
AUTHZ_DB_KEY: renku
AUTHZ_DB_HOST: 127.0.0.1
AUTHZ_DB_GRPC_PORT: "50051"
AUTHZ_DB_KEY: renku
AUTHZ_DB_NO_TLS_CONNECTION: "true"
ZED_ENDPOINT: 127.0.0.1:50051
ZED_TOKEN: renku
Expand Down Expand Up @@ -50,7 +50,7 @@ services:
SWAGGER_JSON_URL: http://localhost:8000/api/data/spec.json
PORT: "8080"
network_mode: service:db

authz:
image: authzed/spicedb:latest-debug
restart: unless-stopped
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ components/renku_data_services/project/apispec.py: components/renku_data_service
poetry run datamodel-codegen --input components/renku_data_services/project/api.spec.yaml --output components/renku_data_services/project/apispec.py --base-class renku_data_services.project.apispec_base.BaseAPISpec $(codegen_params)
components/renku_data_services/session/apispec.py: components/renku_data_services/session/api.spec.yaml
poetry run datamodel-codegen --input components/renku_data_services/session/api.spec.yaml --output components/renku_data_services/session/apispec.py --base-class renku_data_services.session.apispec_base.BaseAPISpec $(codegen_params)
components/renku_data_services/user_preferences/apispec.py: components/renku_data_services/user_preferences/api.spec.yaml
poetry run datamodel-codegen --input components/renku_data_services/user_preferences/api.spec.yaml --output components/renku_data_services/user_preferences/apispec.py --base-class renku_data_services.user_preferences.apispec_base.BaseAPISpec $(codegen_params)
components/renku_data_services/namespace/apispec.py: components/renku_data_services/namespace/api.spec.yaml
poetry run datamodel-codegen --input components/renku_data_services/namespace/api.spec.yaml --output components/renku_data_services/namespace/apispec.py --base-class renku_data_services.namespace.apispec_base.BaseAPISpec $(codegen_params)
components/renku_data_services/secrets/apispec.py: components/renku_data_services/secrets/api.spec.yaml
Expand All @@ -43,7 +41,7 @@ components/renku_data_services/platform/apispec.py: components/renku_data_servic

##@ Apispec

schemas: components/renku_data_services/crc/apispec.py components/renku_data_services/storage/apispec.py components/renku_data_services/users/apispec.py components/renku_data_services/project/apispec.py components/renku_data_services/user_preferences/apispec.py components/renku_data_services/namespace/apispec.py components/renku_data_services/secrets/apispec.py components/renku_data_services/connected_services/apispec.py components/renku_data_services/repositories/apispec.py components/renku_data_services/notebooks/apispec.py components/renku_data_services/platform/apispec.py ## Generate pydantic classes from apispec yaml files
schemas: components/renku_data_services/crc/apispec.py components/renku_data_services/storage/apispec.py components/renku_data_services/users/apispec.py components/renku_data_services/project/apispec.py components/renku_data_services/namespace/apispec.py components/renku_data_services/secrets/apispec.py components/renku_data_services/connected_services/apispec.py components/renku_data_services/repositories/apispec.py components/renku_data_services/notebooks/apispec.py components/renku_data_services/platform/apispec.py ## Generate pydantic classes from apispec yaml files
@echo "generated classes based on ApiSpec"

##@ Avro schemas
Expand Down Expand Up @@ -72,8 +70,6 @@ style_checks: ## Run linting and style checks
@$(call test_apispec_up_to_date,"crc")
@echo "checking storage apispec is up to date"
@$(call test_apispec_up_to_date,"storage")
@echo "checking user preferences apispec is up to date"
@$(call test_apispec_up_to_date,"user_preferences")
@echo "checking users apispec is up to date"
@$(call test_apispec_up_to_date,"users")
@echo "checking project apispec is up to date"
Expand Down
3 changes: 1 addition & 2 deletions bases/renku_data_services/data_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
from renku_data_services.repositories.blueprints import RepositoriesBP
from renku_data_services.session.blueprints import EnvironmentsBP, SessionLaunchersBP
from renku_data_services.storage.blueprints import StorageBP, StorageSchemaBP, StoragesV2BP
from renku_data_services.user_preferences.blueprints import UserPreferencesBP
from renku_data_services.users.blueprints import KCUsersBP, UserSecretsBP
from renku_data_services.users.blueprints import KCUsersBP, UserPreferencesBP, UserSecretsBP


def register_all_handlers(app: Sanic, config: Config) -> Sanic:
Expand Down
10 changes: 2 additions & 8 deletions components/renku_data_services/app_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import renku_data_services.platform
import renku_data_services.repositories
import renku_data_services.storage
import renku_data_services.user_preferences
import renku_data_services.users
from renku_data_services import errors
from renku_data_services.authn.dummy import DummyAuthenticator, DummyUserStore
Expand Down Expand Up @@ -59,8 +58,8 @@
from renku_data_services.secrets.db import UserSecretsRepo
from renku_data_services.session.db import SessionRepository
from renku_data_services.storage.db import StorageRepository, StorageV2Repository
from renku_data_services.user_preferences.config import UserPreferencesConfig
from renku_data_services.user_preferences.db import UserPreferencesRepository
from renku_data_services.users.config import UserPreferencesConfig
from renku_data_services.users.db import UserPreferencesRepository
from renku_data_services.users.db import UserRepo as KcUserRepo
from renku_data_services.users.dummy_kc_api import DummyKeycloakAPI
from renku_data_services.users.kc_api import IKeycloakAPI, KeycloakAPI
Expand Down Expand Up @@ -185,10 +184,6 @@ def __post_init__(self) -> None:
with open(spec_file) as f:
storage_spec = safe_load(f)

spec_file = Path(renku_data_services.user_preferences.__file__).resolve().parent / "api.spec.yaml"
with open(spec_file) as f:
user_preferences_spec = safe_load(f)

spec_file = Path(renku_data_services.users.__file__).resolve().parent / "api.spec.yaml"
with open(spec_file) as f:
users = safe_load(f)
Expand Down Expand Up @@ -220,7 +215,6 @@ def __post_init__(self) -> None:
self.spec = merge_api_specs(
crc_spec,
storage_spec,
user_preferences_spec,
users,
projects,
groups,
Expand Down
2 changes: 0 additions & 2 deletions components/renku_data_services/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from renku_data_services.secrets.orm import BaseORM as secrets
from renku_data_services.session.orm import BaseORM as sessions
from renku_data_services.storage.orm import BaseORM as storage
from renku_data_services.user_preferences.orm import BaseORM as user_preferences
from renku_data_services.users.orm import BaseORM as users

# Interpret the config file for Python logging.
Expand All @@ -31,7 +30,6 @@
secrets.metadata,
sessions.metadata,
storage.metadata,
user_preferences.metadata,
users.metadata,
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""move user preferences to user schema

Revision ID: 17eea03f938e
Revises: dcc1c1ee662f
Create Date: 2024-07-26 14:37:29.556827

"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "17eea03f938e"
down_revision = "dcc1c1ee662f"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"user_preferences",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.String(), nullable=False),
sa.Column(
"pinned_projects",
sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("user_id"),
schema="users",
)
# ### end Alembic commands ###
conn = op.get_bind()
inspector = sa.inspect(conn)
if "user_preferences" in inspector.get_schema_names() and "user_preferences" in inspector.get_table_names(
schema="user_preferences"
):
# migrate old user preferences
statement = sa.sql.text(
"""
INSERT INTO users.user_preferences
SELECT *
FROM user_preferences.user_preferences
"""
)
conn.execute(statement)

op.drop_table("user_preferences", schema="user_preferences")
op.execute("DROP SCHEMA user_preferences")


def downgrade() -> None:
conn = op.get_bind()
inspector = sa.inspect(conn)
if "user_preferences" not in inspector.get_schema_names():
op.execute("CREATE SCHEMA user_preferences")
if "user_preferences" not in inspector.get_table_names(schema="user_preferences"):
op.create_table(
"user_preferences",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.String(), nullable=False),
sa.Column(
"pinned_projects",
sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("user_id"),
schema="user_preferences",
)
statement = sa.sql.text(
"""
INSERT INTO user_preferences.user_preferences
SELECT *
FROM users.user_preferences
"""
)
conn.execute(statement)

# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("user_preferences", schema="users")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "6eccd7d4e3ed"
Expand All @@ -20,21 +18,10 @@


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"user_preferences",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.String(), nullable=False),
sa.Column(
"pinned_projects",
sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("user_id"),
schema="user_preferences",
)
# ### end Alembic commands ###
# this migration in the past created a user_preferences table in the user_preferences schema
# this table is now in the `users` schema, so we don't want to create it here (it's done in a new migration)
# If this migration already ran in the past, it doesn't matter
pass


def downgrade() -> None:
Expand Down

This file was deleted.

153 changes: 0 additions & 153 deletions components/renku_data_services/user_preferences/api.spec.yaml

This file was deleted.

Loading