EOX GitLab Instance

Skip to content
Snippets Groups Projects

Registration routes

Merged Fabian Schindler-Strauss requested to merge routes into main
2 unresolved threads

Adding implementation routes

A Route is bound to a queue and operates on a particular data-type (such as STAC Item, Collection, paths, arbitrary JSON structures).

Backends are also now generic according to its datatype and are now part of the route.

Each route also encapsulates the pre, post, and error handlers.

Example configuration:

routes:
  items:
    path: registrar.route.stac.ItemRoute
    queue: register
    output_queue: next_queue
    backends:
      - path: registrar.backend.eoxserver.ItemBackend
        kwargs:
          instance_base_path: /some/dir
          instance_name: name

    handlers:
      pre:
        - path: some.pre.handler
      post:
        - path: some.post.handler
      error:
        - path: some.error.handler

  collections:
    path: registrar.route.stac.CollectionRoute
    queue: register-collections
    backends:
      - path: registrar.backend.eoxserver.CollectionBackend

  path:
    path: registrar.route.path.PathRoute
    queue: register-paths
    backends:
      - path: some.path.backend

sources: [...]

This is how a STAC Item route can be implemented:

import json
import pystac

class ItemRoute(Route[pystac.Item]):
    """A route implementation for STAC Items"""

    def parse(self, raw: str) -> pystac.Item:
        return pystac.Item.from_dict(json.loads(raw))

    def get_source(
        self, source_cfgs: List[SourceConfig], item: pystac.Item
    ) -> Optional[Source]:
        return get_source(
            source_cfgs, [asset.href for asset in item.assets.values()]
        )

This is how the Backend interface can be satisfied:

from pystac import Item

# ...

class MyItemBackend(Backend[Item]):
    def exists(self, source: Optional[Source], item: Item) -> bool:
        ...

    def register(self, source: Optional[Source], item: Item, replace: bool):
        ...

    def deregister(self, source: Optional[Source], item: Item):
        ...

    def deregister_identifier(self, identifier: str):
        ...
Edited by Fabian Schindler-Strauss

Merge request reports

Pipeline #26264 passed

Pipeline passed for 09dbe62b on routes

Test coverage 0.00% (0.00%) from 1 job
Approval is optional

Merged by Fabian Schindler-StraussFabian Schindler-Strauss 2 years ago (Aug 3, 2022 12:19pm UTC)

Merge details

  • Changes merged into main with 6cf3821f.
  • Deleted the source branch.

Pipeline #26265 passed

Pipeline passed for 6cf3821f on main

Test coverage 0.00% (0.00%) from 1 job

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 95 95 def __repr__(self) -> str:
    96 96 return f"<{self.__class__.__name__} instance_name ={self.instance_name}>"
    97 97
    98 def item_exists(self, source: Optional[Source], item: "Item") -> bool:
    • Method implementation does not check the Source, just existence of Product. Maybe not directly connected to the behavior that the PR introduced, but function description/input parameters are misleading against what it does.

    • There is an abstract base class protocol to be satisfied here. We need the Source as input in registration, and I included it here for vague reasons to mirror the register/deregister API. Probably unnecessary.

    • Please register or sign in to reply
  • 3 3 from tempfile import gettempdir
  • added 15 commits

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • 16168737 - Fixing deregister invocation

    Compare with previous version

  • mentioned in issue #20 (moved)

  • added 2 commits

    • 0346d6fc - Adding `error_queue`
    • 0186e0d3 - Make EOxServer ItemBackend conformant to the new ABC

    Compare with previous version

  • added 1 commit

    • d47f4a3c - Updating registrar chart for new schema

    Compare with previous version

  • added 1 commit

    • b43ebe7c - Adding configuration example

    Compare with previous version

  • added 1 commit

    • 09dbe62b - Updating config schema and sample config

    Compare with previous version

  • Fabian Schindler-Strauss marked this merge request as ready

    marked this merge request as ready

  • mentioned in commit 6cf3821f

  • Please register or sign in to reply
    Loading