From 53cbd78010adc8ef2d173d521e5de35cd49f401d Mon Sep 17 00:00:00 2001 From: Lucjan Dudek Date: Wed, 22 May 2024 10:32:39 +0200 Subject: [PATCH 1/2] Permanently enable mid agreement payments --- ray_on_golem/server/models.py | 4 +- .../server/services/golem/manager_stack.py | 55 +++++++++---------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/ray_on_golem/server/models.py b/ray_on_golem/server/models.py index 7a6f7e4f..b977c0c6 100644 --- a/ray_on_golem/server/models.py +++ b/ray_on_golem/server/models.py @@ -36,7 +36,7 @@ class Config: class PaymentIntervalHours(BaseModel): - minimal: float + minimal: float = 12 optimal: float = None @validator("optimal", always=True, pre=True) @@ -57,7 +57,7 @@ class BudgetControlData(BaseModel): max_cpu_per_hour_price: Optional[float] = None max_env_per_hour_price: Optional[float] = None - payment_interval_hours: Optional[PaymentIntervalHours] = None + payment_interval_hours: PaymentIntervalHours = Field(default_factory=PaymentIntervalHours) class Config: extra = "forbid" diff --git a/ray_on_golem/server/services/golem/manager_stack.py b/ray_on_golem/server/services/golem/manager_stack.py index 67129156..471b98d5 100644 --- a/ray_on_golem/server/services/golem/manager_stack.py +++ b/ray_on_golem/server/services/golem/manager_stack.py @@ -113,38 +113,37 @@ async def create( ) proposal_negotiators = [PaymentPlatformNegotiator()] - if node_config.budget_control.payment_interval_hours is not None: - logger.debug( - "Adding mid agreement payments based on given payment_interval: %s", - node_config.budget_control.payment_interval_hours, - ) - minimal_payment_timeout = timedelta( - hours=node_config.budget_control.payment_interval_hours.minimal - ) - optimal_payment_timeout = timedelta( - hours=node_config.budget_control.payment_interval_hours.optimal - ) + logger.debug( + "Adding mid agreement payments based on given payment_interval: %s", + node_config.budget_control.payment_interval_hours, + ) + minimal_payment_timeout = timedelta( + hours=node_config.budget_control.payment_interval_hours.minimal + ) + optimal_payment_timeout = timedelta( + hours=node_config.budget_control.payment_interval_hours.optimal + ) - payloads.append( - PaymentInfo( - debit_notes_accept_timeout=int( - DEFAULT_DEBIT_NOTES_ACCEPT_TIMEOUT.total_seconds() - ), - debit_notes_interval=int(DEFAULT_DEBIT_NOTE_INTERVAL.total_seconds()), - payment_timeout=int(minimal_payment_timeout.total_seconds()), - ) + payloads.append( + PaymentInfo( + debit_notes_accept_timeout=int( + DEFAULT_DEBIT_NOTES_ACCEPT_TIMEOUT.total_seconds() + ), + debit_notes_interval=int(DEFAULT_DEBIT_NOTE_INTERVAL.total_seconds()), + payment_timeout=int(minimal_payment_timeout.total_seconds()), ) - demand_lifetime = DEFAULT_LONG_RUNNING_DEMAND_LIFETIME - - proposal_negotiators.append( - MidAgreementPaymentsNegotiator( - min_debit_note_interval=DEFAULT_DEBIT_NOTE_INTERVAL, - optimal_debit_note_interval=DEFAULT_DEBIT_NOTE_INTERVAL, - min_payment_timeout=minimal_payment_timeout, - optimal_payment_timeout=optimal_payment_timeout, - ) + ) + demand_lifetime = DEFAULT_LONG_RUNNING_DEMAND_LIFETIME + + proposal_negotiators.append( + MidAgreementPaymentsNegotiator( + min_debit_note_interval=DEFAULT_DEBIT_NOTE_INTERVAL, + optimal_debit_note_interval=DEFAULT_DEBIT_NOTE_INTERVAL, + min_payment_timeout=minimal_payment_timeout, + optimal_payment_timeout=optimal_payment_timeout, ) + ) demand_manager = stack.add_manager( RefreshingDemandManager( From 153440ae3f8e3eca5626dc76ad36cf7988db85c6 Mon Sep 17 00:00:00 2001 From: Lucjan Dudek Date: Wed, 22 May 2024 10:34:41 +0200 Subject: [PATCH 2/2] format --- ray_on_golem/server/services/golem/manager_stack.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ray_on_golem/server/services/golem/manager_stack.py b/ray_on_golem/server/services/golem/manager_stack.py index 471b98d5..eebb0185 100644 --- a/ray_on_golem/server/services/golem/manager_stack.py +++ b/ray_on_golem/server/services/golem/manager_stack.py @@ -127,9 +127,7 @@ async def create( payloads.append( PaymentInfo( - debit_notes_accept_timeout=int( - DEFAULT_DEBIT_NOTES_ACCEPT_TIMEOUT.total_seconds() - ), + debit_notes_accept_timeout=int(DEFAULT_DEBIT_NOTES_ACCEPT_TIMEOUT.total_seconds()), debit_notes_interval=int(DEFAULT_DEBIT_NOTE_INTERVAL.total_seconds()), payment_timeout=int(minimal_payment_timeout.total_seconds()), )