-
Notifications
You must be signed in to change notification settings - Fork 32
✨ Sync task that auto-registers items from VIP as licensed items in the system ⚠️ 🗃️ 🚨 #7140
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
Merged
pcrespov
merged 69 commits into
ITISFoundation:master
from
pcrespov:is7097/fetch-vip-api
Feb 5, 2025
Merged
Changes from 62 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
cf8dd9b
drafts first tests
pcrespov e3d2dc7
respx and httpx
pcrespov 19dff61
drafts test
pcrespov 0def310
gets items
pcrespov 874bda2
get_category_items and settings
pcrespov 764b263
test pass
pcrespov 22bcb39
adds new column
pcrespov f5af34a
adding trashing
pcrespov af2fed0
tests pass
pcrespov f227738
split settings
pcrespov d245e70
split models
pcrespov 3d40c4b
sonar security
pcrespov cb8bca9
notes
pcrespov 992906d
notes
pcrespov 6bdc056
updates db
pcrespov d976a9d
fetch&create
pcrespov 77be4fc
test create
pcrespov ae278f0
if not exists
pcrespov cfc6caa
cleanup
pcrespov fdae0a9
constrinat
pcrespov 326de71
migration:
pcrespov 684e28f
registration
pcrespov 894505a
states
pcrespov 54c69f9
cleanup
pcrespov c016bb0
drafts ideas for rest entyrpoint
pcrespov 60c7d05
cleanup
pcrespov 8738ef2
Merge branch 'master' into is7097/fetch-vip-api
pcrespov 325bb45
fixes migration
pcrespov b70feb4
minor fix on try again
pcrespov 3665e10
update model features
pcrespov a5b3d07
retry policy
pcrespov f8c5878
updates
pcrespov 610131a
tests pass
pcrespov 6bba3e1
result
pcrespov dde6c43
cleanup
pcrespov 06f0c11
drafts syncer
pcrespov 94f0fed
tests pass
pcrespov 75fbcb3
adds deepdiff
pcrespov dfa43f9
drafts task
pcrespov a152413
draft demo
pcrespov 2238c93
fixes dev mode
pcrespov ac35a49
drafts demo
pcrespov 3d2eec6
new fake
pcrespov 6a7822e
tests model guarantees
pcrespov de1ec81
source is respected
pcrespov 0a11891
Merge branch 'master' into is7097/fetch-vip-api
pcrespov f89181c
adapting tests
pcrespov 465153c
no dump
pcrespov 98abd7c
Merge branch 'master' into is7097/fetch-vip-api
pcrespov f86c68e
updates model
pcrespov e98316f
refactoring models
pcrespov ffd14ca
model
pcrespov 8654e70
updates OSA
pcrespov a10f389
fixes mypy
pcrespov b425f76
Merge branch 'master' into is7097/fetch-vip-api
pcrespov 8e22e11
settings
pcrespov 4628cc8
refactors statics
pcrespov e801def
cleanup
pcrespov a882cae
cleanup
pcrespov aeab902
services/webserver api version: 0.51.0 → 0.52.0
pcrespov 1acf690
new example
pcrespov 5d45c0b
test fixes
pcrespov acc8fad
doc
pcrespov bac7e3b
Merge branch 'master' into is7097/fetch-vip-api
pcrespov 850b4ca
@GitHK review: missing todo
pcrespov 39bd21d
@matusdrobuliak66 review: env prefix
pcrespov 42d1317
@YuryHrytsuk review: tests backwards compatiblity
pcrespov 7523b8d
fixes sonarcloud
pcrespov 35041a5
cleanup
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,6 +133,11 @@ DYNAMIC_SCHEDULER_UI_STORAGE_SECRET=adminadmin | |
|
|
||
| FUNCTION_SERVICES_AUTHORS='{"UN": {"name": "Unknown", "email": "[email protected]", "affiliation": "unknown"}}' | ||
|
|
||
| WEBSERVER_LICENSES={} | ||
| LICENSES_ITIS_VIP_SYNCER_ENABLED=false | ||
| ITIS_VIP_API_URL=https://some-api/{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 | ||
|
|
@@ -371,7 +376,6 @@ WEBSERVER_GARBAGE_COLLECTOR=null | |
| WEBSERVER_GROUPS=1 | ||
| WEBSERVER_GUNICORN_CMD_ARGS=--timeout=180 | ||
| WEBSERVER_HOST=webserver | ||
| WEBSERVER_LICENSES=true | ||
| WEBSERVER_LOGIN={} | ||
| WEBSERVER_LOGLEVEL=INFO | ||
| WEBSERVER_META_MODELING=1 | ||
|
|
||
2 changes: 1 addition & 1 deletion
2
...library/src/models_library/api_schemas_resource_usage_tracker/licensed_items_checkouts.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
packages/models-library/src/models_library/licensed_items.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| from datetime import datetime | ||
| from enum import auto | ||
| from typing import Any, NamedTuple, NotRequired, TypeAlias, cast | ||
| from uuid import UUID | ||
|
|
||
| from models_library.resource_tracker import PricingPlanId | ||
| from pydantic import BaseModel, ConfigDict, PositiveInt | ||
| from pydantic.config import JsonDict | ||
| from typing_extensions import TypedDict | ||
|
|
||
| from .products import ProductName | ||
| from .resource_tracker import PricingPlanId | ||
| from .utils.enums import StrAutoEnum | ||
|
|
||
| LicensedItemID: TypeAlias = UUID | ||
|
|
||
|
|
||
| class LicensedResourceType(StrAutoEnum): | ||
| VIP_MODEL = auto() | ||
|
|
||
|
|
||
| VIP_FEATURES_EXAMPLE = { | ||
| "name": "Duke", | ||
| "version": "V2.0", | ||
| "sex": "Male", | ||
| "age": "34 years", | ||
| "weight": "70.2 Kg", | ||
| "height": "1.77 m", | ||
| "date": "2015-03-01", | ||
| "ethnicity": "Caucasian", | ||
| "functionality": "Static", | ||
| "additional_field": "allowed", | ||
| } | ||
|
|
||
|
|
||
| class FeaturesDict(TypedDict): | ||
| name: NotRequired[str] | ||
| version: NotRequired[str] | ||
| sex: NotRequired[str] | ||
| age: NotRequired[str] | ||
| weight: NotRequired[str] | ||
| height: NotRequired[str] | ||
| date: str | ||
| ethnicity: NotRequired[str] | ||
| functionality: NotRequired[str] | ||
|
|
||
|
|
||
| VIP_DETAILS_EXAMPLE = { | ||
| "id": 1, | ||
| "description": "custom description", | ||
| "thumbnail": "custom description", | ||
| "features": VIP_FEATURES_EXAMPLE, | ||
| "doi": "custom value", | ||
| "license_key": "custom value", | ||
| "license_version": "custom value", | ||
| "protection": "custom value", | ||
| "available_from_url": "custom value", | ||
| "additional_field": "trimmed if rest", | ||
| } | ||
|
|
||
|
|
||
| # | ||
| # DB | ||
| # | ||
|
|
||
|
|
||
| class LicensedItemDB(BaseModel): | ||
| licensed_item_id: LicensedItemID | ||
| display_name: str | ||
|
|
||
| licensed_resource_name: str | ||
| licensed_resource_type: LicensedResourceType | ||
| licensed_resource_data: dict[str, Any] | None | ||
|
|
||
| pricing_plan_id: PricingPlanId | None | ||
| product_name: ProductName | None | ||
|
|
||
| # states | ||
| created: datetime | ||
| modified: datetime | ||
| trashed: datetime | None | ||
|
|
||
| model_config = ConfigDict(from_attributes=True) | ||
|
|
||
|
|
||
| class LicensedItemUpdateDB(BaseModel): | ||
| display_name: str | None = None | ||
| licensed_resource_name: str | None = None | ||
| pricing_plan_id: PricingPlanId | None = None | ||
| trash: bool | None = None | ||
|
|
||
|
|
||
| class LicensedItem(BaseModel): | ||
| licensed_item_id: LicensedItemID | ||
| display_name: str | ||
| licensed_resource_name: str | ||
| licensed_resource_type: LicensedResourceType | ||
| licensed_resource_data: dict[str, Any] | ||
| pricing_plan_id: PricingPlanId | ||
| created_at: datetime | ||
| modified_at: datetime | ||
|
|
||
| @staticmethod | ||
| def _update_json_schema_extra(schema: JsonDict) -> None: | ||
| schema.update( | ||
| { | ||
| "examples": [ | ||
| { | ||
| "licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1", | ||
| "display_name": "my best model", | ||
| "licensed_resource_name": "best-model", | ||
| "licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}", | ||
| "licensed_resource_data": cast(JsonDict, VIP_DETAILS_EXAMPLE), | ||
| "pricing_plan_id": "15", | ||
| "created_at": "2024-12-12 09:59:26.422140", | ||
| "modified_at": "2024-12-12 09:59:26.422140", | ||
| } | ||
| ] | ||
| } | ||
| ) | ||
|
|
||
| model_config = ConfigDict(json_schema_extra=_update_json_schema_extra) | ||
|
|
||
|
|
||
| class LicensedItemPage(NamedTuple): | ||
| total: PositiveInt | ||
| items: list[LicensedItem] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.