weaver.quotation.estimation

Module Contents

weaver.quotation.estimation.EstimatorInputLiteral[source]
weaver.quotation.estimation.LOGGER[source]
class weaver.quotation.estimation.CurrencyConverter(name: str, url: str, parser: Callable[[weaver.typedefs.JSON | str], weaver.typedefs.Number], **kwargs: Any)[source]

Generic definition of a currency converter.

url: str = None[source]
name: str = None[source]
token: str = ''[source]
json: bool = True[source]
parser: Callable[[weaver.typedefs.JSON | str], weaver.typedefs.Number | str] = None[source]
convert(currency: weaver.typedefs.Number | decimal.Decimal, from_currency: str, to_currency: str) decimal.Decimal[source]
weaver.quotation.estimation.CURRENCY_CONVERTERS: Dict[str, CurrencyConverter][source]
weaver.quotation.estimation.get_quote_estimator_config(process: weaver.datatype.Process, ignore_error: bool = False) weaver.typedefs.JSON[source]

Obtain the estimator from the process after validation.

weaver.quotation.estimation.validate_quote_estimator_config(estimator: weaver.typedefs.JSON) weaver.typedefs.JSON[source]

Validate a quote estimator configuration against the expected schema.

weaver.quotation.estimation.prepare_quote_estimator_config(quote: weaver.datatype.Quote, process: weaver.datatype.Process) weaver.typedefs.JSON[source]

Retrieves submitted quote input parameters and prepares them for the estimation using the process configuration.

All submitted inputs are made available to the estimator(s). It is up to them to employ relevant inputs based on the quote estimation configuration applicable for this process.

According to the quote-estimator schema, complex inputs must provide the file size, while literals provide the values directly. Weights are retrieved from the process configuration, but must be joined along inputs definition.

weaver.quotation.estimation.get_currency(request: weaver.typedefs.AnyRequestType) str[source]
weaver.quotation.estimation.request_convert_cost(method: weaver.typedefs.AnyRequestMethod, url: str, kwargs: weaver.utils.RequestCachingKeywords) requests.Response[source]
weaver.quotation.estimation.convert_exchange_rate(amount: decimal.Decimal, convert_currency: str, original_currency: str | None = None) weaver.typedefs.Price[source]

Convert the cost value using the requested currency.

weaver.quotation.estimation.estimate_process_quote(quote: weaver.datatype.Quote, process: weaver.datatype.Process, settings: weaver.typedefs.AnySettingsContainer | None = None) weaver.datatype.Quote[source]

Estimate execution price and time for an atomic Process operation.

Employs provided inputs and expected outputs and relevant metadata for the Process.

Parameters:
  • quote – Quote with references to process parameters.

  • process – Targeted process for execution.

  • settings – Application settings.

Returns:

Updated quote with estimates.

weaver.quotation.estimation.estimate_workflow_quote(quote: weaver.datatype.Quote, process: weaver.datatype.Process, settings: weaver.typedefs.AnySettingsContainer | None = None) weaver.datatype.Quote[source]

Loop Workflow sub-Process steps to get their respective Quote.

weaver.quotation.estimation.execute_quote_estimator(task: celery.app.task.Task, quote_id: weaver.typedefs.AnyUUID) weaver.quotation.status.AnyQuoteStatus[source]

Estimate Quote parameters for the Process execution.

Parameters:
  • task – Celery Task that processes this quote.

  • quote_id – Quote identifier associated to the requested estimation for the process execution.

Returns:

Estimated quote parameters.