arrakis-server 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. arrakis_server-0.1.0/.gitignore +12 -0
  2. arrakis_server-0.1.0/.gitlab-ci.yml +82 -0
  3. arrakis_server-0.1.0/AUTHORS.md +5 -0
  4. arrakis_server-0.1.0/Dockerfile +21 -0
  5. arrakis_server-0.1.0/LICENSE +195 -0
  6. arrakis_server-0.1.0/Makefile +29 -0
  7. arrakis_server-0.1.0/PKG-INFO +110 -0
  8. arrakis_server-0.1.0/README.md +36 -0
  9. arrakis_server-0.1.0/arrakis_server/__init__.py +13 -0
  10. arrakis_server-0.1.0/arrakis_server/__main__.py +129 -0
  11. arrakis_server-0.1.0/arrakis_server/_version.py +16 -0
  12. arrakis_server-0.1.0/arrakis_server/arrow.py +85 -0
  13. arrakis_server-0.1.0/arrakis_server/backends/__init__.py +29 -0
  14. arrakis_server-0.1.0/arrakis_server/backends/mock/__init__.py +191 -0
  15. arrakis_server-0.1.0/arrakis_server/backends/mock/channels/H1_channels.toml +3834 -0
  16. arrakis_server-0.1.0/arrakis_server/backends/mock/channels/L1_channels.toml +3434 -0
  17. arrakis_server-0.1.0/arrakis_server/backends/mock/channels/__init__.py +0 -0
  18. arrakis_server-0.1.0/arrakis_server/channel.py +77 -0
  19. arrakis_server-0.1.0/arrakis_server/constants.py +11 -0
  20. arrakis_server-0.1.0/arrakis_server/metadata.py +209 -0
  21. arrakis_server-0.1.0/arrakis_server/partition.py +97 -0
  22. arrakis_server-0.1.0/arrakis_server/py.typed +0 -0
  23. arrakis_server-0.1.0/arrakis_server/schemas.py +113 -0
  24. arrakis_server-0.1.0/arrakis_server/scope.py +319 -0
  25. arrakis_server-0.1.0/arrakis_server/server.py +535 -0
  26. arrakis_server-0.1.0/arrakis_server/tests/__init__.py +0 -0
  27. arrakis_server-0.1.0/arrakis_server/tests/conftest.py +26 -0
  28. arrakis_server-0.1.0/arrakis_server/tests/data/channels.toml +14 -0
  29. arrakis_server-0.1.0/arrakis_server/tests/test_api.py +48 -0
  30. arrakis_server-0.1.0/arrakis_server/tests/test_server.py +107 -0
  31. arrakis_server-0.1.0/arrakis_server/traits.py +208 -0
  32. arrakis_server-0.1.0/docs/gen_ref_nav.py +49 -0
  33. arrakis_server-0.1.0/docs/index.md +1 -0
  34. arrakis_server-0.1.0/docs/usage.md +3 -0
  35. arrakis_server-0.1.0/environment.yml +15 -0
  36. arrakis_server-0.1.0/mkdocs.yml +56 -0
  37. arrakis_server-0.1.0/pyproject.toml +172 -0
@@ -0,0 +1,12 @@
1
+ *~
2
+
3
+ # build artifacts
4
+ *.egg-info
5
+ build/
6
+ dist/
7
+ site/
8
+ __pycache__
9
+ */_version.py
10
+
11
+ # patches
12
+ *.patch
@@ -0,0 +1,82 @@
1
+
2
+ include:
3
+ # -- python -----------------
4
+ - component: git.ligo.org/computing/gitlab/components/python/sdist@1
5
+ - component: git.ligo.org/computing/gitlab/components/python/wheel@1
6
+ - component: git.ligo.org/computing/gitlab/components/python/code-quality@1
7
+ inputs:
8
+ analyzer: "ruff"
9
+ requirements: "-r requirements-lint.txt"
10
+ - component: git.ligo.org/computing/gitlab/components/python/dependency-scanning@1
11
+ - component: git.ligo.org/computing/gitlab/components/python/type-checking@1
12
+ - component: git.ligo.org/computing/gitlab/components/python/test@1
13
+ inputs:
14
+ install_extra: test
15
+ python_versions:
16
+ - "3.11"
17
+ - "3.12"
18
+ # -- docker -----------------
19
+ - component: git.ligo.org/computing/gitlab/components/docker/build@1
20
+ inputs:
21
+ image_tag: $CI_COMMIT_SHA
22
+ - component: git.ligo.org/computing/gitlab/components/docker/push@1
23
+ inputs:
24
+ pull_image_tag: $CI_COMMIT_SHA
25
+ push_image_tag: $CI_COMMIT_REF_NAME
26
+ push_when: "all"
27
+ tag_latest: false
28
+ rules:
29
+ - if: $CI_COMMIT_BRANCH
30
+ - if: $CI_COMMIT_TAG !~ /^(\d+\.)?(\d+\.)?(\*|\d+)$/
31
+ - component: git.ligo.org/computing/gitlab/components/docker/push@1
32
+ inputs:
33
+ pull_image_tag: $CI_COMMIT_SHA
34
+ push_image_tag: $CI_COMMIT_TAG
35
+ push_when: "tags"
36
+ tag_latest: true
37
+ rules:
38
+ # tag latest only on new versions
39
+ - if: $CI_COMMIT_TAG =~ /^(\d+\.)?(\d+\.)?(\*|\d+)$/
40
+ # -- docs -------------------
41
+ - component: git.ligo.org/computing/gitlab/components/mkdocs/build@1
42
+ inputs:
43
+ requirements: "-r requirements-docs.txt"
44
+ - component: git.ligo.org/computing/gitlab/components/mkdocs/pages@1
45
+ inputs:
46
+ pages_when: "default"
47
+
48
+ # -- customisations
49
+
50
+ # have Docker build depend on wheel
51
+ build:
52
+ needs:
53
+ - wheel
54
+
55
+ docker_push_gitlab:
56
+ rules:
57
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
58
+ when: never
59
+ - when: always
60
+
61
+ ruff:
62
+ needs:
63
+ - requirements
64
+
65
+ mkdocs:
66
+ needs:
67
+ - requirements
68
+
69
+ # -- requirements
70
+ requirements:
71
+ stage: build
72
+ image: python:3.12
73
+ script:
74
+ - python -m pip install pipx
75
+ - pipx ensurepath
76
+ - source ~/.bashrc
77
+ - pipx install hatch
78
+ - hatch dep show requirements --feature docs > requirements-docs.txt
79
+ - hatch dep show requirements --feature lint > requirements-lint.txt
80
+ artifacts:
81
+ paths:
82
+ - requirements-*.txt
@@ -0,0 +1,5 @@
1
+ ## Maintainers
2
+
3
+ | Name | Email |
4
+ |---------------------|---------------------------------------|
5
+ | Patrick Godwin | <patrick.godwin@ligo.org> |
@@ -0,0 +1,21 @@
1
+ FROM mambaorg/micromamba:2.0
2
+
3
+ # install git (for arrakis-server packages)
4
+ USER root
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ git \
7
+ && rm -rf /var/lib/apt/lists/*
8
+ USER $MAMBA_USER
9
+
10
+ # install dependencies
11
+ COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/environment.yml
12
+ RUN micromamba install -y -f /tmp/environment.yml && \
13
+ micromamba clean --all --yes
14
+
15
+ # install arrakis-server
16
+ ARG MAMBA_DOCKERFILE_ACTIVATE=1
17
+ COPY --chown=$MAMBA_USER:$MAMBA_USER *.whl /tmp
18
+ RUN pip install --no-deps /tmp/*.whl
19
+
20
+ ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "arrakis-server"]
21
+ CMD ["--backend", "mock"]
@@ -0,0 +1,195 @@
1
+ Copyright (c) 2022, California Institute of Technology and contributors
2
+
3
+ This program is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU Lesser General Public
5
+ License as published by the Free Software Foundation; either
6
+ version 3 of the License, or (at your option) any later version.
7
+
8
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
13
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
16
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
+
20
+ Neither the name of the California Institute of Technology (Caltech),
21
+ Massachusetts Institute of Technology (M.I.T.), nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ This software is distributed under the GNU Lesser General Public
26
+ License Version 3. A copy is included below, and can also be obtained
27
+ at http://www.gnu.org/licenses
28
+
29
+ -----------------------------------------------------------------------
30
+
31
+ GNU LESSER GENERAL PUBLIC LICENSE
32
+ Version 3, 29 June 2007
33
+
34
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
35
+ Everyone is permitted to copy and distribute verbatim copies
36
+ of this license document, but changing it is not allowed.
37
+
38
+
39
+ This version of the GNU Lesser General Public License incorporates
40
+ the terms and conditions of version 3 of the GNU General Public
41
+ License, supplemented by the additional permissions listed below.
42
+
43
+ 0. Additional Definitions.
44
+
45
+ As used herein, "this License" refers to version 3 of the GNU Lesser
46
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
47
+ General Public License.
48
+
49
+ "The Library" refers to a covered work governed by this License,
50
+ other than an Application or a Combined Work as defined below.
51
+
52
+ An "Application" is any work that makes use of an interface provided
53
+ by the Library, but which is not otherwise based on the Library.
54
+ Defining a subclass of a class defined by the Library is deemed a mode
55
+ of using an interface provided by the Library.
56
+
57
+ A "Combined Work" is a work produced by combining or linking an
58
+ Application with the Library. The particular version of the Library
59
+ with which the Combined Work was made is also called the "Linked
60
+ Version".
61
+
62
+ The "Minimal Corresponding Source" for a Combined Work means the
63
+ Corresponding Source for the Combined Work, excluding any source code
64
+ for portions of the Combined Work that, considered in isolation, are
65
+ based on the Application, and not on the Linked Version.
66
+
67
+ The "Corresponding Application Code" for a Combined Work means the
68
+ object code and/or source code for the Application, including any data
69
+ and utility programs needed for reproducing the Combined Work from the
70
+ Application, but excluding the System Libraries of the Combined Work.
71
+
72
+ 1. Exception to Section 3 of the GNU GPL.
73
+
74
+ You may convey a covered work under sections 3 and 4 of this License
75
+ without being bound by section 3 of the GNU GPL.
76
+
77
+ 2. Conveying Modified Versions.
78
+
79
+ If you modify a copy of the Library, and, in your modifications, a
80
+ facility refers to a function or data to be supplied by an Application
81
+ that uses the facility (other than as an argument passed when the
82
+ facility is invoked), then you may convey a copy of the modified
83
+ version:
84
+
85
+ a) under this License, provided that you make a good faith effort to
86
+ ensure that, in the event an Application does not supply the
87
+ function or data, the facility still operates, and performs
88
+ whatever part of its purpose remains meaningful, or
89
+
90
+ b) under the GNU GPL, with none of the additional permissions of
91
+ this License applicable to that copy.
92
+
93
+ 3. Object Code Incorporating Material from Library Header Files.
94
+
95
+ The object code form of an Application may incorporate material from
96
+ a header file that is part of the Library. You may convey such object
97
+ code under terms of your choice, provided that, if the incorporated
98
+ material is not limited to numerical parameters, data structure
99
+ layouts and accessors, or small macros, inline functions and templates
100
+ (ten or fewer lines in length), you do both of the following:
101
+
102
+ a) Give prominent notice with each copy of the object code that the
103
+ Library is used in it and that the Library and its use are
104
+ covered by this License.
105
+
106
+ b) Accompany the object code with a copy of the GNU GPL and this license
107
+ document.
108
+
109
+ 4. Combined Works.
110
+
111
+ You may convey a Combined Work under terms of your choice that,
112
+ taken together, effectively do not restrict modification of the
113
+ portions of the Library contained in the Combined Work and reverse
114
+ engineering for debugging such modifications, if you also do each of
115
+ the following:
116
+
117
+ a) Give prominent notice with each copy of the Combined Work that
118
+ the Library is used in it and that the Library and its use are
119
+ covered by this License.
120
+
121
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
122
+ document.
123
+
124
+ c) For a Combined Work that displays copyright notices during
125
+ execution, include the copyright notice for the Library among
126
+ these notices, as well as a reference directing the user to the
127
+ copies of the GNU GPL and this license document.
128
+
129
+ d) Do one of the following:
130
+
131
+ 0) Convey the Minimal Corresponding Source under the terms of this
132
+ License, and the Corresponding Application Code in a form
133
+ suitable for, and under terms that permit, the user to
134
+ recombine or relink the Application with a modified version of
135
+ the Linked Version to produce a modified Combined Work, in the
136
+ manner specified by section 6 of the GNU GPL for conveying
137
+ Corresponding Source.
138
+
139
+ 1) Use a suitable shared library mechanism for linking with the
140
+ Library. A suitable mechanism is one that (a) uses at run time
141
+ a copy of the Library already present on the user's computer
142
+ system, and (b) will operate properly with a modified version
143
+ of the Library that is interface-compatible with the Linked
144
+ Version.
145
+
146
+ e) Provide Installation Information, but only if you would otherwise
147
+ be required to provide such information under section 6 of the
148
+ GNU GPL, and only to the extent that such information is
149
+ necessary to install and execute a modified version of the
150
+ Combined Work produced by recombining or relinking the
151
+ Application with a modified version of the Linked Version. (If
152
+ you use option 4d0, the Installation Information must accompany
153
+ the Minimal Corresponding Source and Corresponding Application
154
+ Code. If you use option 4d1, you must provide the Installation
155
+ Information in the manner specified by section 6 of the GNU GPL
156
+ for conveying Corresponding Source.)
157
+
158
+ 5. Combined Libraries.
159
+
160
+ You may place library facilities that are a work based on the
161
+ Library side by side in a single library together with other library
162
+ facilities that are not Applications and are not covered by this
163
+ License, and convey such a combined library under terms of your
164
+ choice, if you do both of the following:
165
+
166
+ a) Accompany the combined library with a copy of the same work based
167
+ on the Library, uncombined with any other library facilities,
168
+ conveyed under the terms of this License.
169
+
170
+ b) Give prominent notice with the combined library that part of it
171
+ is a work based on the Library, and explaining where to find the
172
+ accompanying uncombined form of the same work.
173
+
174
+ 6. Revised Versions of the GNU Lesser General Public License.
175
+
176
+ The Free Software Foundation may publish revised and/or new versions
177
+ of the GNU Lesser General Public License from time to time. Such new
178
+ versions will be similar in spirit to the present version, but may
179
+ differ in detail to address new problems or concerns.
180
+
181
+ Each version is given a distinguishing version number. If the
182
+ Library as you received it specifies that a certain numbered version
183
+ of the GNU Lesser General Public License "or any later version"
184
+ applies to it, you have the option of following the terms and
185
+ conditions either of that published version or of any later version
186
+ published by the Free Software Foundation. If the Library as you
187
+ received it does not specify a version number of the GNU Lesser
188
+ General Public License, you may choose any version of the GNU Lesser
189
+ General Public License ever published by the Free Software Foundation.
190
+
191
+ If the Library as you received it specifies that a proxy can decide
192
+ whether future versions of the GNU Lesser General Public License shall
193
+ apply, that proxy's public statement of acceptance of any version is
194
+ permanent authorization for you to choose that version for the
195
+ Library.
@@ -0,0 +1,29 @@
1
+ .PHONY: help
2
+ help :
3
+ @echo
4
+ @echo 'Commands:'
5
+ @echo
6
+ @echo ' make test run tests'
7
+ @echo ' make lint run linter'
8
+ @echo ' make format run code formatter'
9
+ @echo ' make check run static type checker'
10
+ @echo
11
+
12
+ .PHONY: test
13
+ test :
14
+ pytest -v --cov=arrakis_server --cov-report=term-missing .
15
+
16
+ .PHONY: lint
17
+ lint :
18
+ ruff check
19
+
20
+ .PHONY: format
21
+ format :
22
+ ruff format
23
+
24
+ .PHONY: check
25
+ check :
26
+ mypy .
27
+
28
+ .PHONY: all
29
+ all : format lint check test
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: arrakis-server
3
+ Version: 0.1.0
4
+ Summary: Arrakis server
5
+ Project-URL: Homepage, https://git.ligo.org/ngdd/arrakis-server
6
+ Project-URL: Documentation, https://docs.ligo.org/ngdd/arrakis-server
7
+ Project-URL: Issue Tracker, https://git.ligo.org/ngdd/arrakis-server/issues
8
+ Project-URL: Source Code, https://git.ligo.org/ngdd/arrakis-server.git
9
+ Author-email: Patrick Godwin <patrick.godwin@ligo.org>
10
+ Maintainer-email: Patrick Godwin <patrick.godwin@ligo.org>
11
+ License-Expression: GPL-3.0-or-later
12
+ License-File: AUTHORS.md
13
+ License-File: LICENSE
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
18
+ Classifier: Natural Language :: English
19
+ Classifier: Operating System :: POSIX
20
+ Classifier: Operating System :: POSIX :: Linux
21
+ Classifier: Programming Language :: Python
22
+ Classifier: Programming Language :: Python :: 3
23
+ Classifier: Topic :: Scientific/Engineering
24
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
25
+ Classifier: Topic :: Scientific/Engineering :: Physics
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: appdirs
28
+ Requires-Dist: arrakis>=0.2
29
+ Requires-Dist: gpstime
30
+ Requires-Dist: numpy
31
+ Requires-Dist: pandas
32
+ Requires-Dist: pyarrow
33
+ Requires-Dist: ruamel-yaml
34
+ Requires-Dist: sympy
35
+ Requires-Dist: toml
36
+ Requires-Dist: typing-extensions
37
+ Provides-Extra: dev
38
+ Requires-Dist: markdown-callouts>=0.2; extra == 'dev'
39
+ Requires-Dist: markdown-exec>=0.5; extra == 'dev'
40
+ Requires-Dist: mkdocs-coverage>=0.2; extra == 'dev'
41
+ Requires-Dist: mkdocs-gen-files>=0.3; extra == 'dev'
42
+ Requires-Dist: mkdocs-literate-nav>=0.4; extra == 'dev'
43
+ Requires-Dist: mkdocs-material-igwn; extra == 'dev'
44
+ Requires-Dist: mkdocs-section-index>=0.3; extra == 'dev'
45
+ Requires-Dist: mkdocs>=1.3; extra == 'dev'
46
+ Requires-Dist: mkdocstrings[python]; extra == 'dev'
47
+ Requires-Dist: mypy; extra == 'dev'
48
+ Requires-Dist: mypy-extensions; extra == 'dev'
49
+ Requires-Dist: pip; extra == 'dev'
50
+ Requires-Dist: pytest; extra == 'dev'
51
+ Requires-Dist: pytest-cov; extra == 'dev'
52
+ Requires-Dist: ruff; extra == 'dev'
53
+ Requires-Dist: toml>=0.10; extra == 'dev'
54
+ Provides-Extra: docs
55
+ Requires-Dist: markdown-callouts>=0.2; extra == 'docs'
56
+ Requires-Dist: markdown-exec>=0.5; extra == 'docs'
57
+ Requires-Dist: mkdocs-coverage>=0.2; extra == 'docs'
58
+ Requires-Dist: mkdocs-gen-files>=0.3; extra == 'docs'
59
+ Requires-Dist: mkdocs-literate-nav>=0.4; extra == 'docs'
60
+ Requires-Dist: mkdocs-material-igwn; extra == 'docs'
61
+ Requires-Dist: mkdocs-section-index>=0.3; extra == 'docs'
62
+ Requires-Dist: mkdocs>=1.3; extra == 'docs'
63
+ Requires-Dist: mkdocstrings[python]; extra == 'docs'
64
+ Requires-Dist: toml>=0.10; extra == 'docs'
65
+ Provides-Extra: lint
66
+ Requires-Dist: mypy; extra == 'lint'
67
+ Requires-Dist: mypy-extensions; extra == 'lint'
68
+ Requires-Dist: pip; extra == 'lint'
69
+ Requires-Dist: ruff; extra == 'lint'
70
+ Provides-Extra: test
71
+ Requires-Dist: pytest; extra == 'test'
72
+ Requires-Dist: pytest-cov; extra == 'test'
73
+ Description-Content-Type: text/markdown
74
+
75
+ <h1 align="center">arrakis-server</h1>
76
+
77
+ <p align="center">Arrakis server</p>
78
+
79
+ <p align="center">
80
+ <a href="https://git.ligo.org/ngdd/arrakis-server/-/pipelines/latest">
81
+ <img alt="ci" src="https://git.ligo.org/ngdd/arrakis-server/badges/main/pipeline.svg" />
82
+ </a>
83
+ <a href="https://ngdd.docs.ligo.org/arrakis-server/">
84
+ <img alt="documentation" src="https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat" />
85
+ </a>
86
+ </p>
87
+
88
+ ---
89
+
90
+ ## Installation
91
+
92
+ ```
93
+ pip install git+https://git.ligo.org/ngdd/arrakis-server.git
94
+ ```
95
+
96
+ ## Docker
97
+
98
+ ```
99
+ docker run --net=host -it docker://containers.ligo.org/ngdd/arrakis-server:main
100
+ ```
101
+
102
+ ## Features
103
+
104
+ TODO
105
+
106
+ ## Quickstart
107
+
108
+ 1. Run `arrakis-server -b mock`.
109
+ 2. Make client requests through the [Arrakis client library](https://git.ligo.org/ngdd/arrakis-python).
110
+ 3. Shut down the server instance with Ctrl-C.
@@ -0,0 +1,36 @@
1
+ <h1 align="center">arrakis-server</h1>
2
+
3
+ <p align="center">Arrakis server</p>
4
+
5
+ <p align="center">
6
+ <a href="https://git.ligo.org/ngdd/arrakis-server/-/pipelines/latest">
7
+ <img alt="ci" src="https://git.ligo.org/ngdd/arrakis-server/badges/main/pipeline.svg" />
8
+ </a>
9
+ <a href="https://ngdd.docs.ligo.org/arrakis-server/">
10
+ <img alt="documentation" src="https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat" />
11
+ </a>
12
+ </p>
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ ```
19
+ pip install git+https://git.ligo.org/ngdd/arrakis-server.git
20
+ ```
21
+
22
+ ## Docker
23
+
24
+ ```
25
+ docker run --net=host -it docker://containers.ligo.org/ngdd/arrakis-server:main
26
+ ```
27
+
28
+ ## Features
29
+
30
+ TODO
31
+
32
+ ## Quickstart
33
+
34
+ 1. Run `arrakis-server -b mock`.
35
+ 2. Make client requests through the [Arrakis client library](https://git.ligo.org/ngdd/arrakis-python).
36
+ 3. Shut down the server instance with Ctrl-C.
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2022, California Institute of Technology and contributors
2
+ #
3
+ # You should have received a copy of the licensing terms for this
4
+ # software included in the file "LICENSE" located in the top-level
5
+ # directory of this package. If you did not, you can view a copy at
6
+ # https://git.ligo.org/ngdd/arrakis-server/-/raw/main/LICENSE
7
+
8
+ try:
9
+ from ._version import version as __version__
10
+ except ModuleNotFoundError:
11
+ import setuptools_scm
12
+
13
+ __version__ = setuptools_scm.get_version(fallback_version="?.?.?")
@@ -0,0 +1,129 @@
1
+ import argparse
2
+ import logging
3
+ import pathlib
4
+ import sys
5
+
6
+ from . import __version__, traits
7
+ from .backends import BackendType
8
+ from .constants import DEFAULT_LOCATION
9
+ from .scope import ScopeMap
10
+ from .server import ArrakisFlightServer
11
+
12
+ logger = logging.getLogger("arrakis")
13
+
14
+
15
+ def get_log_level(args: argparse.Namespace) -> int:
16
+ """Determine the log level from logging options."""
17
+ if args.quiet:
18
+ return logging.WARNING
19
+ elif args.verbose:
20
+ return logging.DEBUG
21
+ else:
22
+ return logging.INFO
23
+
24
+
25
+ def main() -> None:
26
+ parser = argparse.ArgumentParser(prog="arrakis-server")
27
+ parser.add_argument(
28
+ "--version",
29
+ action="version",
30
+ version=__version__,
31
+ )
32
+ group = parser.add_mutually_exclusive_group()
33
+ group.add_argument(
34
+ "-q",
35
+ "--quiet",
36
+ action="store_true",
37
+ help="If set, only display warnings and errors.",
38
+ )
39
+ group.add_argument(
40
+ "-v",
41
+ "--verbose",
42
+ action="store_true",
43
+ help="If set, display additional logging messages.",
44
+ )
45
+ parser.add_argument(
46
+ "-u",
47
+ "--url",
48
+ default=DEFAULT_LOCATION,
49
+ help=f"Serve requests at this URL. Default: {DEFAULT_LOCATION}",
50
+ )
51
+ parser.add_argument(
52
+ "-s",
53
+ "--scope-map-file",
54
+ type=pathlib.Path,
55
+ help="Scope map file",
56
+ )
57
+ parser.add_argument(
58
+ "-b",
59
+ "--backend",
60
+ type=str.upper,
61
+ choices=BackendType.__members__,
62
+ default="MOCK",
63
+ help="The data backend to use. Default: MOCK",
64
+ )
65
+ parser.add_argument(
66
+ "--backend-server-url",
67
+ help=(
68
+ "URL pointing to a running backend server. "
69
+ "Required if using KAFKA or NDS backend."
70
+ ),
71
+ )
72
+ parser.add_argument(
73
+ "--mock-channel-file",
74
+ action="append",
75
+ type=pathlib.Path,
76
+ help=(
77
+ "Channel definition file for MOCK backend. May be specified multiple times."
78
+ ),
79
+ )
80
+ args = parser.parse_args()
81
+
82
+ # set up logger
83
+ logger = logging.getLogger("arrakis")
84
+ log_level = get_log_level(args)
85
+ logger.setLevel(log_level)
86
+ handler = logging.StreamHandler(sys.stderr)
87
+ handler.setLevel(log_level)
88
+ formatter = logging.Formatter("%(asctime)s | arrakis : %(levelname)s : %(message)s")
89
+ handler.setFormatter(formatter)
90
+ logger.addHandler(handler)
91
+
92
+ backend_type = BackendType[args.backend.upper()]
93
+
94
+ ##############################
95
+
96
+ logger.info("Arrakis server %s", __version__)
97
+
98
+ # load scope map
99
+ scope_map = None
100
+ if args.scope_map_file:
101
+ logger.info("loading global scope map:")
102
+ scope_map = ScopeMap.load(args.scope_map_file)
103
+ for loc, info in scope_map.servers.items():
104
+ logger.info(" %s: %s", loc, info.domains)
105
+
106
+ # initialize the backend
107
+ logger.info("initializing %s...", backend_type)
108
+ backend: traits.MaybeBackend
109
+ match backend_type:
110
+ case BackendType.NONE: # type: ignore
111
+ backend = None
112
+ case _:
113
+ backend = backend_type.value.from_args(args)
114
+
115
+ # serve requests
116
+ logger.info("initializing flight server...")
117
+ server = ArrakisFlightServer(
118
+ url=args.url,
119
+ backend=backend,
120
+ scope_map=scope_map,
121
+ )
122
+ server.serve()
123
+
124
+
125
+ if __name__ == "__main__":
126
+ try:
127
+ main()
128
+ except KeyboardInterrupt:
129
+ pass
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.1.0'
16
+ __version_tuple__ = version_tuple = (0, 1, 0)