:mod:`weaver.store.mongodb` =========================== .. py:module:: weaver.store.mongodb .. autoapi-nested-parse:: Stores to read/write data to from/to mongodb using pymongo. Module Contents --------------- .. data:: JobListAndCount .. data:: LOGGER .. py:class:: MongodbStore(collection, sane_name_config=None) Bases: :class:`object` Base class extended by all concrete store implementations. .. classmethod:: get_args_kwargs(cls, *args, **kwargs) Filters :class:`MongodbStore`-specific arguments to safely pass them down its ``__init__``. .. py:class:: MongodbServiceStore(*args, **kwargs) Bases: :class:`weaver.store.base.StoreServices`, :class:`weaver.store.mongodb.MongodbStore` Registry for OWS services. Uses mongodb to store service url and attributes. .. method:: save_service(self, service, overwrite=True, request=None) Stores an OWS service in mongodb. .. method:: delete_service(self, name, request=None) Removes service from mongodb storage. .. method:: list_services(self, request=None) Lists all services in mongodb storage. .. method:: fetch_by_name(self, name, visibility=None, request=None) Gets service for given ``name`` from mongodb storage. .. method:: fetch_by_url(self, url, request=None) Gets service for given ``url`` from mongodb storage. .. method:: clear_services(self, request=None) Removes all OWS services from mongodb storage. .. py:class:: MongodbProcessStore(*args, **kwargs) Bases: :class:`weaver.store.base.StoreProcesses`, :class:`weaver.store.mongodb.MongodbStore` Registry for processes. Uses mongodb to store processes and attributes. .. method:: _add_process(self, process) .. staticmethod:: _get_process_field(process, function_dict) Takes a lambda expression or a dict of process-specific lambda expressions to retrieve a field. Validates that the passed process object is one of the supported types. :param process: process to retrieve the field from. :param function_dict: lambda or dict of lambda of process type :return: retrieved field if the type was supported :raises: ProcessInstanceError on invalid process type .. method:: _get_process_id(self, process) .. method:: _get_process_type(self, process) .. method:: _get_process_endpoint_wps1(self, process) .. method:: save_process(self, process, overwrite=True, request=None) Stores a process in storage. :param process: An instance of :class:`weaver.datatype.Process`. :param overwrite: Overwrite the matching process instance by name if conflicting. :param request: .. method:: delete_process(self, process_id, visibility=None, request=None) Removes process from database, optionally filtered by visibility. If ``visibility=None``, the process is deleted (if existing) regardless of its visibility value. .. method:: list_processes(self, visibility=None, request=None) Lists all processes in database, optionally filtered by `visibility`. :param visibility: One value amongst `weaver.visibility`. :param request: .. method:: fetch_by_id(self, process_id, visibility=None, request=None) Get process for given `process_id` from storage, optionally filtered by `visibility`. If ``visibility=None``, the process is retrieved (if existing) regardless of its visibility value. :param process_id: process identifier :param visibility: one value amongst `weaver.visibility`. :param request: :return: An instance of :class:`weaver.datatype.Process`. .. method:: get_visibility(self, process_id, request=None) Get `visibility` of a process. :return: One value amongst `weaver.visibility`. .. method:: set_visibility(self, process_id, visibility, request=None) Set `visibility` of a process. :param visibility: One value amongst `weaver.visibility`. :param process_id: :param request: :raises: ``TypeError`` or ``ValueError`` in case of invalid parameter. .. method:: clear_processes(self, request=None) Clears all processes from the store. :param request: .. py:class:: MongodbJobStore(*args, **kwargs) Bases: :class:`weaver.store.base.StoreJobs`, :class:`weaver.store.mongodb.MongodbStore` Registry for process jobs tracking. Uses mongodb to store job attributes. .. method:: save_job(self, task_id, process, service=None, inputs=None, is_workflow=False, user_id=None, execute_async=True, custom_tags=None, access=None, notification_email=None, accept_language=None) Stores a job in mongodb. .. method:: update_job(self, job) Updates a job parameters in mongodb storage. :param job: instance of ``weaver.datatype.Job``. .. method:: delete_job(self, job_id, request=None) Removes job from mongodb storage. .. method:: fetch_by_id(self, job_id, request=None) Gets job for given ``job_id`` from mongodb storage. .. method:: list_jobs(self, request=None) Lists all jobs in mongodb storage. For user-specific access to available jobs, use :meth:`MongodbJobStore.find_jobs` instead. .. method:: find_jobs(self, request, process=None, service=None, tags=None, access=None, notification_email=None, status=None, sort=None, page=0, limit=10, group_by=None) Finds all jobs in mongodb storage matching search filters and obtain results with requested paging or grouping. :param request: request that lead to this call to obtain permissions and user id. :param process: process name to filter matching jobs. :param service: service name to filter matching jobs. :param tags: list of tags to filter matching jobs. :param access: access visibility to filter matching jobs (default: PUBLIC). :param notification_email: notification email to filter matching jobs. :param status: status to filter matching jobs. :param sort: field which is used for sorting results (default: creation date, descending). :param page: page number to return when using result paging (only when not using ``group_by``). :param limit: number of jobs per page when using result paging (only when not using ``group_by``). :param group_by: one or many fields specifying categories to form matching groups of jobs (paging disabled). :returns: (list of jobs matching paging OR list of {categories, list of jobs, count}) AND total of matched job .. rubric:: Example Using paging (default), result will be in the form:: ( [Job(1), Job(2), Job(3), ...], ) Where ```` will indicate the complete count of matched jobs with filters, but the list of jobs will be limited only to ``page`` index and ``limit`` specified. Using grouping with a list of field specified with ``group_by``, results will be in the form:: ( [{category: {field1: valueA, field2: valueB, ...}, [Job(1), Job(2), ...], count: }, {category: {field1: valueC, field2: valueD, ...}, [Job(x), Job(y), ...], count: }, ... ], ) Where ```` will again indicate all matched jobs by every category combined, and ```` will indicate the amount of jobs matched for each individual category. Also, ``category`` will indicate values of specified fields (from ``group_by``) that compose corresponding jobs with matching values. .. method:: clear_jobs(self, request=None) Removes all jobs from mongodb storage. .. py:class:: MongodbQuoteStore(*args, **kwargs) Bases: :class:`weaver.store.base.StoreQuotes`, :class:`weaver.store.mongodb.MongodbStore` Registry for quotes. Uses mongodb to store quote attributes. .. method:: save_quote(self, quote) Stores a quote in mongodb. .. method:: fetch_by_id(self, quote_id) Gets quote for given ``quote_id`` from mongodb storage. .. method:: list_quotes(self) Lists all quotes in mongodb storage. .. method:: find_quotes(self, process_id=None, page=0, limit=10, sort=None) Finds all quotes in mongodb storage matching search filters. Returns a tuple of filtered ``items`` and their ``count``, where ``items`` can have paging and be limited to a maximum per page, but ``count`` always indicate the `total` number of matches. .. py:class:: MongodbBillStore(*args, **kwargs) Bases: :class:`weaver.store.base.StoreBills`, :class:`weaver.store.mongodb.MongodbStore` Registry for bills. Uses mongodb to store bill attributes. .. method:: save_bill(self, bill) Stores a bill in mongodb. .. method:: fetch_by_id(self, bill_id) Gets bill for given ``bill_id`` from mongodb storage. .. method:: list_bills(self) Lists all bills in mongodb storage. .. method:: find_bills(self, quote_id=None, page=0, limit=10, sort=None) Finds all bills in mongodb storage matching search filters. Returns a tuple of filtered ``items`` and their ``count``, where ``items`` can have paging and be limited to a maximum per page, but ``count`` always indicate the `total` number of matches.