weaver.quotation.estimation =========================== .. py:module:: weaver.quotation.estimation Module Contents --------------- .. py:data:: EstimatorInputLiteral .. py:data:: LOGGER .. py:class:: CurrencyConverter(name: str, url: str, parser: Callable[[Union[weaver.typedefs.JSON, str]], weaver.typedefs.Number], **kwargs: Any) Generic definition of a currency converter. .. py:attribute:: url :type: str :value: None .. py:attribute:: name :type: str :value: None .. py:attribute:: token :type: str :value: '' .. py:attribute:: json :type: bool :value: True .. py:attribute:: parser :type: Callable[[Union[weaver.typedefs.JSON, str]], Union[weaver.typedefs.Number, str]] :value: None .. py:method:: convert(currency: Union[weaver.typedefs.Number, decimal.Decimal], from_currency: str, to_currency: str) -> decimal.Decimal .. py:data:: CURRENCY_CONVERTERS :type: Dict[str, CurrencyConverter] .. py:function:: get_quote_estimator_config(process: weaver.datatype.Process, ignore_error: bool = False) -> weaver.typedefs.JSON Obtain the estimator from the process after validation. .. py:function:: validate_quote_estimator_config(estimator: weaver.typedefs.JSON) -> weaver.typedefs.JSON Validate a quote estimator configuration against the expected schema. .. py:function:: prepare_quote_estimator_config(quote: weaver.datatype.Quote, process: weaver.datatype.Process) -> weaver.typedefs.JSON 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. .. seealso:: https://github.com/crim-ca/weaver/blob/master/weaver/schemas/quote-estimator.yaml .. py:function:: get_currency(request: weaver.typedefs.AnyRequestType) -> str .. py:function:: request_convert_cost(method: weaver.typedefs.AnyRequestMethod, url: str, kwargs: weaver.utils.RequestCachingKeywords) -> requests.Response .. py:function:: convert_exchange_rate(amount: decimal.Decimal, convert_currency: str, original_currency: Optional[str] = None) -> weaver.typedefs.Price Convert the cost value using the requested currency. .. py:function:: estimate_process_quote(quote: weaver.datatype.Quote, process: weaver.datatype.Process, settings: Optional[weaver.typedefs.AnySettingsContainer] = None) -> weaver.datatype.Quote Estimate execution price and time for an atomic :term:`Process` operation. Employs provided inputs and expected outputs and relevant metadata for the :term:`Process`. :param quote: Quote with references to process parameters. :param process: Targeted process for execution. :param settings: Application settings. :returns: Updated quote with estimates. .. py:function:: estimate_workflow_quote(quote: weaver.datatype.Quote, process: weaver.datatype.Process, settings: Optional[weaver.typedefs.AnySettingsContainer] = None) -> weaver.datatype.Quote Loop :term:`Workflow` sub-:term:`Process` steps to get their respective :term:`Quote`. .. py:function:: execute_quote_estimator(task: celery.app.task.Task, quote_id: weaver.typedefs.AnyUUID) -> weaver.quotation.status.AnyQuoteStatus Estimate :term:`Quote` parameters for the :term:`Process` execution. :param task: Celery Task that processes this quote. :param quote_id: Quote identifier associated to the requested estimation for the process execution. :return: Estimated quote parameters.