• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DataBiosphere / azul / 25584544628

08 May 2026 11:28PM UTC coverage: 84.943% (-0.1%) from 85.076%
25584544628

push

github

dsotirho-ucsc
[u R a A] Promotion 2026-05-05 prod (#7992, PR #8001)

20134 of 23703 relevant lines covered (84.94%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.0
src/azul/service/source_controller.py
1
import logging
1✔
2

3
from chalice.app import (
1✔
4
    TooManyRequestsError,
5
    UnauthorizedError,
6
)
7

8
from azul import (
1✔
9
    CatalogName,
10
)
11
from azul.auth import (
1✔
12
    Authentication,
13
)
14
from azul.chalice import (
1✔
15
    BadGatewayError,
16
    Controller,
17
    TemporaryRedirectError,
18
)
19
from azul.http import (
1✔
20
    LimitedTimeoutException,
21
    TooManyRequestsException,
22
)
23
from azul.lib import (
1✔
24
    cached_property,
25
)
26
from azul.lib.types import (
1✔
27
    JSONs,
28
)
29
from azul.service.source_service import (
1✔
30
    SourceService,
31
)
32

33
log = logging.getLogger(__name__)
1✔
34

35

36
class SourceController(Controller):
1✔
37

38
    @cached_property
1✔
39
    def _source_service(self) -> SourceService:
1✔
40
        return SourceService()
1✔
41

42
    def list_sources(self,
1✔
43
                     catalog: CatalogName,
44
                     authentication: Authentication | None
45
                     ) -> JSONs:
46
        try:
1✔
47
            sources = self._source_service.list_sources(catalog, authentication)
1✔
48
        except PermissionError:
×
49
            raise UnauthorizedError
×
50
        except LimitedTimeoutException as e:
×
51
            raise TemporaryRedirectError(*e.args)
×
52
        except TooManyRequestsException as e:
×
53
            raise TooManyRequestsError(*e.args)
×
54
        else:
55
            authoritative_source_ids = {source.ref.id for source in sources}
1✔
56
            cached_source_ids = self._list_source_ids(catalog, authentication)
1✔
57
            # For optimized performance, the cache may include source IDs that
58
            # are accessible but are not configured for indexing. Therefore, we
59
            # expect the set of actual sources to be a subset of the cached
60
            # sources.
61
            diff = authoritative_source_ids - cached_source_ids
1✔
62
            if diff:
1✔
63
                log.debug(diff)
×
64
                raise BadGatewayError('Inconsistent response from repository')
×
65
            return [
1✔
66
                {
67
                    'sourceId': source.ref.id,
68
                    'sourceSpec': source.ref.spec.to_json(),
69
                    'sourceConfig': source.config.to_json()
70
                }
71
                for source in sources
72
            ]
73

74
    def _list_source_ids(self,
1✔
75
                         catalog: CatalogName,
76
                         authentication: Authentication | None
77
                         ) -> set[str]:
78
        try:
1✔
79
            source_ids = self._source_service.list_source_ids(catalog, authentication)
1✔
80
        except PermissionError:
×
81
            raise UnauthorizedError
×
82
        except LimitedTimeoutException as e:
×
83
            raise TemporaryRedirectError(*e.args)
×
84
        except TooManyRequestsException as e:
×
85
            raise TooManyRequestsError(*e.args)
×
86
        else:
87
            return source_ids
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc