Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cf8dd9b
drafts first tests
pcrespov Jan 29, 2025
e3d2dc7
respx and httpx
pcrespov Jan 29, 2025
19dff61
drafts test
pcrespov Jan 29, 2025
0def310
gets items
pcrespov Jan 29, 2025
874bda2
get_category_items and settings
pcrespov Jan 29, 2025
764b263
test pass
pcrespov Jan 29, 2025
22bcb39
adds new column
pcrespov Jan 29, 2025
f5af34a
adding trashing
pcrespov Jan 29, 2025
af2fed0
tests pass
pcrespov Jan 29, 2025
f227738
split settings
pcrespov Jan 30, 2025
d245e70
split models
pcrespov Jan 30, 2025
3d40c4b
sonar security
pcrespov Jan 30, 2025
cb8bca9
notes
pcrespov Jan 30, 2025
992906d
notes
pcrespov Jan 30, 2025
6bdc056
updates db
pcrespov Jan 30, 2025
d976a9d
fetch&create
pcrespov Jan 30, 2025
77be4fc
test create
pcrespov Jan 30, 2025
ae278f0
if not exists
pcrespov Jan 30, 2025
cfc6caa
cleanup
pcrespov Jan 30, 2025
fdae0a9
constrinat
pcrespov Jan 30, 2025
326de71
migration:
pcrespov Jan 30, 2025
684e28f
registration
pcrespov Jan 30, 2025
894505a
states
pcrespov Jan 30, 2025
54c69f9
cleanup
pcrespov Jan 30, 2025
c016bb0
drafts ideas for rest entyrpoint
pcrespov Jan 30, 2025
60c7d05
cleanup
pcrespov Jan 31, 2025
8738ef2
Merge branch 'master' into is7097/fetch-vip-api
pcrespov Jan 31, 2025
325bb45
fixes migration
pcrespov Jan 31, 2025
b70feb4
minor fix on try again
pcrespov Jan 31, 2025
3665e10
update model features
pcrespov Jan 31, 2025
a5b3d07
retry policy
pcrespov Jan 31, 2025
f8c5878
updates
pcrespov Jan 31, 2025
610131a
tests pass
pcrespov Jan 31, 2025
6bba3e1
result
pcrespov Jan 31, 2025
dde6c43
cleanup
pcrespov Jan 31, 2025
06f0c11
drafts syncer
pcrespov Jan 31, 2025
94f0fed
tests pass
pcrespov Jan 31, 2025
75fbcb3
adds deepdiff
pcrespov Jan 31, 2025
dfa43f9
drafts task
pcrespov Jan 31, 2025
a152413
draft demo
pcrespov Feb 3, 2025
2238c93
fixes dev mode
pcrespov Feb 3, 2025
ac35a49
drafts demo
pcrespov Feb 3, 2025
3d2eec6
new fake
pcrespov Feb 3, 2025
6a7822e
tests model guarantees
pcrespov Feb 3, 2025
de1ec81
source is respected
pcrespov Feb 3, 2025
0a11891
Merge branch 'master' into is7097/fetch-vip-api
pcrespov Feb 3, 2025
f89181c
adapting tests
pcrespov Feb 3, 2025
322e5cf
1.part of spliting licensed_items to licenses + licensed_resources
matusdrobuliak66 Feb 5, 2025
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: 4 additions & 0 deletions .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ DYNAMIC_SCHEDULER_UI_STORAGE_SECRET=adminadmin

FUNCTION_SERVICES_AUTHORS='{"UN": {"name": "Unknown", "email": "[email protected]", "affiliation": "unknown"}}'


ITIS_VIP_API_URL=https://itis.swiss/PD_DirectDownload/getDownloadableItems/{category}
ITIS_VIP_CATEGORIES='{"HumanWholeBody": "Humans", "HumanBodyRegion": "Humans (Region)", "AnimalWholeBody": "Animal"}'

# Can use 'docker run -it itisfoundation/invitations:latest simcore-service-invitations generate-dotenv --auto-password'
INVITATIONS_DEFAULT_PRODUCT=osparc
INVITATIONS_HOST=invitations
Expand Down
51 changes: 51 additions & 0 deletions packages/models-library/src/models_library/licenses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from datetime import datetime
from typing import TypeAlias
from uuid import UUID

from pydantic import BaseModel, ConfigDict

from .licensed_items import LicensedResourceType
from .products import ProductName
from .resource_tracker import PricingPlanId

LicenseID: TypeAlias = UUID


#
# DB
#


class LicenseDB(BaseModel):
license_id: LicenseID
display_name: str
licensed_resource_type: LicensedResourceType
pricing_plan_id: PricingPlanId
product_name: ProductName

# states
created: datetime
modified: datetime

model_config = ConfigDict(from_attributes=True)


class LicenseUpdateDB(BaseModel):
display_name: str | None = None
pricing_plan_id: PricingPlanId | None = None


#
# License Domain
#


class License(BaseModel):
license_id: LicenseID
display_name: str
licensed_resource_type: LicensedResourceType
resources: list[dict]
pricing_plan_id: PricingPlanId
product_name: ProductName

model_config = ConfigDict(from_attributes=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
"""add licenses table

Revision ID: 2215301c2496
Revises: e71ea59858f4
Create Date: 2025-02-04 15:26:27.325429+00:00

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

# revision identifiers, used by Alembic.
revision = "2215301c2496"
down_revision = "e71ea59858f4"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"licensed_resources",
sa.Column(
"licensed_item_id",
postgresql.UUID(as_uuid=True),
server_default=sa.text("gen_random_uuid()"),
nullable=False,
),
sa.Column("display_name", sa.String(), nullable=False),
sa.Column("licensed_resource_name", sa.String(), nullable=False),
sa.Column(
"licensed_resource_type",
sa.Enum("VIP_MODEL", name="licensedresourcetype"),
nullable=False,
),
sa.Column(
"licensed_resource_data",
postgresql.JSONB(astext_type=sa.Text()),
nullable=True,
),
sa.Column("pricing_plan_id", sa.BigInteger(), nullable=True),
sa.Column("product_name", sa.String(), nullable=True),
sa.Column(
"created",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column(
"modified",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column(
"trashed",
sa.DateTime(timezone=True),
nullable=True,
comment="The date and time when the licensed_item was marked as trashed. Null if the licensed_item has not been trashed [default].",
),
sa.ForeignKeyConstraint(
["pricing_plan_id"],
["resource_tracker_pricing_plans.pricing_plan_id"],
name="fk_resource_tracker_license_packages_pricing_plan_id",
onupdate="CASCADE",
ondelete="RESTRICT",
),
sa.ForeignKeyConstraint(
["product_name"],
["products.name"],
name="fk_resource_tracker_license_packages_product_name",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("licensed_item_id"),
# sa.UniqueConstraint(
# "licensed_resource_name",
# "licensed_resource_type",
# name="uq_licensed_resource_name_type",
# ),
)
op.create_table(
"licenses",
sa.Column(
"license_id",
postgresql.UUID(as_uuid=True),
server_default=sa.text("gen_random_uuid()"),
nullable=False,
),
sa.Column("display_name", sa.String(), nullable=False),
sa.Column(
"licensed_resource_type",
sa.Enum("VIP_MODEL", name="licensedresourcetype"),
nullable=False,
),
sa.Column("pricing_plan_id", sa.BigInteger(), nullable=False),
sa.Column("product_name", sa.String(), nullable=False),
sa.Column(
"created",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column(
"modified",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.ForeignKeyConstraint(
["pricing_plan_id"],
["resource_tracker_pricing_plans.pricing_plan_id"],
name="fk_resource_tracker_license_packages_pricing_plan_id",
onupdate="CASCADE",
ondelete="RESTRICT",
),
sa.ForeignKeyConstraint(
["product_name"],
["products.name"],
name="fk_resource_tracker_license_packages_product_name",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("license_id"),
)
op.create_table(
"license_to_resource",
sa.Column("license_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("licensed_item_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column(
"created",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column(
"modified",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.ForeignKeyConstraint(
["license_id"],
["licenses.license_id"],
name="fk_license_to_resource_license_id",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.ForeignKeyConstraint(
["licensed_item_id"],
["licensed_resources.licensed_item_id"],
name="fk_license_to_resource_licensed_item_id",
onupdate="CASCADE",
ondelete="CASCADE",
),
)
op.drop_table("licensed_items")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"licensed_items",
sa.Column(
"licensed_item_id",
postgresql.UUID(),
server_default=sa.text("gen_random_uuid()"),
autoincrement=False,
nullable=False,
),
sa.Column(
"licensed_resource_name", sa.VARCHAR(), autoincrement=False, nullable=False
),
sa.Column(
"licensed_resource_type",
postgresql.ENUM("VIP_MODEL", name="licensedresourcetype"),
autoincrement=False,
nullable=False,
),
sa.Column("pricing_plan_id", sa.BIGINT(), autoincrement=False, nullable=True),
sa.Column("product_name", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column(
"created",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=False,
),
sa.Column(
"modified",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("now()"),
autoincrement=False,
nullable=False,
),
sa.Column(
"licensed_resource_data",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=True,
),
sa.Column(
"trashed",
postgresql.TIMESTAMP(timezone=True),
autoincrement=False,
nullable=True,
comment="The date and time when the licensed_item was marked as trashed. Null if the licensed_item has not been trashed [default].",
),
sa.Column("display_name", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["pricing_plan_id"],
["resource_tracker_pricing_plans.pricing_plan_id"],
name="fk_resource_tracker_license_packages_pricing_plan_id",
onupdate="CASCADE",
ondelete="RESTRICT",
),
sa.ForeignKeyConstraint(
["product_name"],
["products.name"],
name="fk_resource_tracker_license_packages_product_name",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("licensed_item_id", name="licensed_items_pkey"),
sa.UniqueConstraint(
"licensed_resource_name",
"licensed_resource_type",
name="uq_licensed_resource_name_type",
),
)
op.drop_table("license_to_resource")
op.drop_table("licenses")
op.drop_table("licensed_resources")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""add uniqu constraint in licensed_items

Revision ID: e71ea59858f4
Revises: 7d1c6425a51d"
Create Date: 2025-01-30 18:42:15.192968+00:00

"""
from alembic import op

# revision identifiers, used by Alembic.
revision = "e71ea59858f4"
down_revision = "7d1c6425a51d"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(
"uq_licensed_resource_name_type",
"licensed_items",
["licensed_resource_name", "licensed_resource_type"],
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"uq_licensed_resource_name_type", "licensed_items", type_="unique"
)
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from ._common import RefActions, column_created_datetime, column_modified_datetime
from .base import metadata

license_to_resource = sa.Table(
"license_to_resource",
metadata,
sa.Column(
"license_id",
postgresql.UUID(as_uuid=True),
sa.ForeignKey(
"licenses.license_id",
name="fk_license_to_resource_license_id",
onupdate=RefActions.CASCADE,
ondelete=RefActions.CASCADE,
),
nullable=False,
),
sa.Column(
"licensed_item_id", # <-- This will be renamed to "licensed_resource_id"
postgresql.UUID(as_uuid=True),
sa.ForeignKey(
"licensed_resources.licensed_item_id", # <-- This will be renamed to "licensed_resource_id"
name="fk_license_to_resource_licensed_item_id",
onupdate=RefActions.CASCADE,
ondelete=RefActions.CASCADE,
),
nullable=False,
),
column_created_datetime(timezone=True),
column_modified_datetime(timezone=True),
)
Loading
Loading