Skip to content

Commit

Permalink
Permanently enable mid agreement payments (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucekdudek authored May 22, 2024
1 parent 7f3c4cf commit e5a3661
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions ray_on_golem/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Config:


class PaymentIntervalHours(BaseModel):
minimal: float
minimal: float = 12
optimal: float = None

@validator("optimal", always=True, pre=True)
Expand All @@ -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"
Expand Down
53 changes: 25 additions & 28 deletions ray_on_golem/server/services/golem/manager_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,38 +113,35 @@ 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(
Expand Down

0 comments on commit e5a3661

Please sign in to comment.