-
Notifications
You must be signed in to change notification settings - Fork 27
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
✨ Introduce wallet exchange 🗃️ #7033
base: master
Are you sure you want to change the base?
✨ Introduce wallet exchange 🗃️ #7033
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7033 +/- ##
==========================================
- Coverage 87.57% 85.27% -2.30%
==========================================
Files 1629 1574 -55
Lines 63454 62079 -1375
Branches 2047 1794 -253
==========================================
- Hits 55569 52940 -2629
- Misses 7549 8828 +1279
+ Partials 336 311 -25
Continue to review full report in Codecov by Sentry.
|
….com:matusdrobuliak66/osparc-simcore into changing-wallet-after-running-out-of-credits
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, but the change in the efs-guardian. I would like to discuss this.
@@ -38,16 +38,50 @@ class ServiceRunStatus(StrAutoEnum): | |||
|
|||
|
|||
class CreditTransactionStatus(StrAutoEnum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: this is always in sync with CreditTransactionStatus
in resource_tracker_credit_transactions.py
? do you test this?
Q: same thing with CreditClassification
# pagination | ||
offset: int = 0, | ||
limit: int = 20, | ||
# ordering | ||
order_by: OrderBy | None = None, | ||
) -> ServiceRunPage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these comments really useful? pagination, well I'd say it is pretty clear already. and ordering for something called order_by. I'd'say that is not necessary.
) | ||
except DBProjectNotFoundError as exc: | ||
_logger.warning( | ||
"Project %s not found, this should not happen, please investigate (contact MD)", | ||
exc.msg_template, | ||
except DBProjectNotFoundError: | ||
_logger.info( | ||
"Project %s not found. Removing EFS data for project {project_id} started", | ||
project_id, | ||
) | ||
await efs_manager.remove_project_efs_data(project_id) | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a weird merge and looks wrong. can we discuss that one?
# attribute filtering | ||
service_run_status: ServiceRunStatus | None = None, | ||
started_from: datetime | None = None, | ||
started_until: datetime | None = None, | ||
transaction_status: CreditTransactionStatus | None = None, | ||
project_id: ProjectID | None = None, | ||
# pagination | ||
offset: int, | ||
limit: int, | ||
# ordering | ||
order_by: OrderBy | None = None, | ||
) -> list[ServiceRunWithCreditsDB]: | ||
async with transaction_context(engine, connection) as conn: | ||
query = ( | ||
) -> tuple[int, list[ServiceRunWithCreditsDB]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I see this is a new pattern.
I would propose the following instead of adding comments like these everywhere:
filter_by_service_run_status
filter_by_started_from
filter_by_started_until
page_offset
page_limit
order_by
product_name: ProductName, | ||
wallet_id: WalletID, | ||
project_id: ProjectID, | ||
transaction_status: CreditTransactionStatus | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here you do not put #attribute filtering
comment?
As I said I prefer not to have these kind of comments all over the place. usually that means that something is unclear.
new_wallet_transaction = CreditTransactionCreateBody( | ||
product_name=product_name, | ||
wallet_id=_WALLET_ID_FOR_PAYING_DEBT__NOT_ENOUGH_CREDITS, | ||
wallet_name="new wallet", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
faker.name()
wallet_id=_WALLET_ID_FOR_PAYING_DEBT__NOT_ENOUGH_CREDITS, | ||
wallet_name="new wallet", | ||
user_id=_USER_ID_1, | ||
user_email="[email protected]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
faker.email()
@@ -240,7 +240,7 @@ async def test_process_event_functions( | |||
postgres_db, msg.service_run_id, modified_at | |||
) | |||
assert output.osparc_credits < first_credits_used | |||
assert output.transaction_status == "BILLED" | |||
assert output.transaction_status == "IN_DEBT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not using CreditTransactionStatus.IN_DEBT.value ?
@@ -127,6 +134,12 @@ async def open_project(request: web.Request) -> web.Response: | |||
), | |||
) | |||
|
|||
await projects_service.raise_if_project_is_in_debt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_project_financial_status
? ;)
|
||
class _PayProjectDebtBody(BaseModel): | ||
amount: Annotated[Decimal, Field(lt=0)] | ||
model_config = ConfigDict(extra="forbid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: here I was under the assumption that we "accept clients that add stuff since we do not care and ignore whatever fields a client might add" and that we forbid for stuff we return. Or is there a reason to forbid any extra field?
What do these changes do?
Currently, a project's connected wallet can go into a negative balance. This occurs because we have a policy to avoid interrupting users' computational jobs when their wallet reaches 0 credits—only dynamic services are stopped.
This PR:
Example:
The project transaction is in debt:
After the user pays off the debt using another wallet (triggering 2 new transactions between the wallets), the project transaction status changes from IN_DEBT to BILLED, unblocking the project.
Related issue/s
How to test
Dev-ops checklist