Skip to content
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

Permanently enable mid agreement payments #244

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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
Loading