arcsecond 4.4.4__tar.gz → 4.6.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.
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.github/workflows/pythonpublish.yml +1 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.github/workflows/tests.yml +5 -5
- {arcsecond-4.4.4 → arcsecond-4.6.0}/PKG-INFO +1 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cli.py +8 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/__init__.py +4 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/composedoc.py +8 -0
- arcsecond-4.6.0/arcsecond/hosting/disks.py +292 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/doctor.py +17 -1
- arcsecond-4.6.0/arcsecond/hosting/forecast.py +75 -0
- arcsecond-4.6.0/arcsecond/hosting/license.py +610 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/lifecycle.py +3 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/local.py +30 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/network/__init__.py +31 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/network/guard.py +1 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/network/manifest.toml +27 -3
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/network/outbound.py +1 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/network/sheet.py +8 -4
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/stack.py +4 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/pyproject.toml +1 -1
- arcsecond-4.6.0/tests/test_hosting_disks.py +125 -0
- arcsecond-4.6.0/tests/test_hosting_forecast.py +82 -0
- arcsecond-4.6.0/tests/test_hosting_license.py +306 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_local.py +47 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_network_guard.py +13 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_network_manifest.py +22 -2
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_network_sheet.py +8 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_token.py +1 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/uv.lock +1 -1
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.docker/Dockerfile_postgres +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.docker/Dockerfile_redis +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.flake8 +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.gitattributes +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.github/dependabot.yml +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/.gitignore +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/LICENSE +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/Makefile +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/README.md +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/__version__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/alpaca/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/alpaca/commands.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/alpaca/dome_probe.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/alpaca/probe.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/alpaca/telescope_probe.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/api/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/api/config.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/api/constants.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/api/endpoint.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/api/main.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/api/resources.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/auth.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/resources.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/constants.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/context.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/datafiles/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/datafiles/context.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/datafiles/errors.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/datafiles/uploader.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/datafiles/utils.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/errors.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/logger.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/uploader.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/utils.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploader/walker.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/cloud/uploads.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/docgen.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/errors.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/backups.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/database.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/docker/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/docker/docker-compose.yml +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/network/probe.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/skybrightness.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/token.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/hosting/utils.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/autostart.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/commands.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/detection.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/proxy.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/registry.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/runtime.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/sources/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/sources/base.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/sources/filewatch.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/sources/mdns.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/sources/network.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/sources/opencv.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/imagesources/store.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/options.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/arcsecond/targets.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/examples/example_upload_files.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/requirements.txt +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/setup.cfg +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/setup.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/sonar-project.properties +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/api/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/api/test_api.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/api/test_api_endpoint.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/api/test_config.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/api/test_config_pointer.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/api/test_targets.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/datafiles/__init__.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/datafiles/test_uploader_errors.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/datafiles/test_uploader_full_process.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/datafiles/test_uploader_init.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/datafiles/test_uploader_prepare.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/cloud/uploader/datafiles/test_uploader_upload.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/conftest.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/fixtures/docker-compose-6.2.yml +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/fixtures/docker-compose-6.4.yml +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/fixtures/file1.fits +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_alpaca_probe.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_cli.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_cli_api_commands.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_docgen.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_backups_install_dir.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_backups_restore.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_composedoc.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_database.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_doctor.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_lifecycle.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_network_outbound.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_network_probe.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_skybrightness.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_stack.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_hosting_utils_secret_key.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_autostart.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_commands.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_detection.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_mdns.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_network.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_proxy.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_store.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_imagesources_webcam.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/test_targets_planning.py +0 -0
- {arcsecond-4.4.4 → arcsecond-4.6.0}/tests/utils.py +0 -0
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
- uses: actions/checkout@v5
|
|
18
18
|
|
|
19
19
|
- name: Install uv
|
|
20
|
-
uses: astral-sh/setup-uv@
|
|
20
|
+
uses: astral-sh/setup-uv@v7
|
|
21
21
|
with:
|
|
22
22
|
python-version: ${{ matrix.python-version }}
|
|
23
23
|
enable-cache: true
|
|
@@ -51,7 +51,7 @@ jobs:
|
|
|
51
51
|
- uses: actions/checkout@v5
|
|
52
52
|
|
|
53
53
|
- name: Install uv
|
|
54
|
-
uses: astral-sh/setup-uv@
|
|
54
|
+
uses: astral-sh/setup-uv@v7
|
|
55
55
|
with:
|
|
56
56
|
python-version: '3.12'
|
|
57
57
|
enable-cache: true
|
|
@@ -70,13 +70,13 @@ jobs:
|
|
|
70
70
|
- uses: actions/checkout@v5
|
|
71
71
|
|
|
72
72
|
- name: Download coverage artifact
|
|
73
|
-
uses: actions/download-artifact@
|
|
73
|
+
uses: actions/download-artifact@v7
|
|
74
74
|
with:
|
|
75
75
|
name: coverage
|
|
76
76
|
path: .
|
|
77
77
|
|
|
78
78
|
- name: SonarQube Scan
|
|
79
|
-
uses: SonarSource/sonarqube-scan-action@
|
|
79
|
+
uses: SonarSource/sonarqube-scan-action@v7
|
|
80
80
|
env:
|
|
81
81
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
82
82
|
|
|
@@ -86,7 +86,7 @@ jobs:
|
|
|
86
86
|
- uses: actions/checkout@v5
|
|
87
87
|
|
|
88
88
|
- name: Install uv
|
|
89
|
-
uses: astral-sh/setup-uv@
|
|
89
|
+
uses: astral-sh/setup-uv@v7
|
|
90
90
|
with:
|
|
91
91
|
python-version: '3.12'
|
|
92
92
|
enable-cache: true
|
|
@@ -13,7 +13,9 @@ from arcsecond.docgen import docs
|
|
|
13
13
|
from arcsecond.hosting import (
|
|
14
14
|
backups,
|
|
15
15
|
db,
|
|
16
|
+
disks_group,
|
|
16
17
|
doctor_cmd,
|
|
18
|
+
license_group,
|
|
17
19
|
logs,
|
|
18
20
|
restart,
|
|
19
21
|
setup,
|
|
@@ -79,12 +81,18 @@ main.add_command(doctor_cmd)
|
|
|
79
81
|
# Its name until 4.4, kept so that scripts and habits go on working.
|
|
80
82
|
main.add_command(doctor_cmd, name="check")
|
|
81
83
|
|
|
84
|
+
# Is the installation licensed, as the backend itself sees it, and if not why.
|
|
85
|
+
main.add_command(license_group)
|
|
86
|
+
|
|
82
87
|
# The access token Arcsecond gave the observatory, once per machine.
|
|
83
88
|
main.add_command(token_group)
|
|
84
89
|
|
|
85
90
|
# Browse and restore Arcsecond.local DB backups.
|
|
86
91
|
main.add_command(backups)
|
|
87
92
|
|
|
93
|
+
# The disks of this machine to attach as Local Disk storages.
|
|
94
|
+
main.add_command(disks_group)
|
|
95
|
+
|
|
88
96
|
# Manage the Arcsecond.local database (e.g. `arcsecond db set-password`).
|
|
89
97
|
main.add_command(db)
|
|
90
98
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from .backups import backups
|
|
2
2
|
from .database import db
|
|
3
|
+
from .disks import disks_group
|
|
3
4
|
|
|
4
5
|
# doctor_cmd, not doctor: `doctor` is also this package's module of that name,
|
|
5
6
|
# and re-exporting the command under it would shadow the module for tests.
|
|
6
7
|
from .doctor import doctor_cmd
|
|
8
|
+
from .license import license_group
|
|
7
9
|
from .lifecycle import logs, restart, start, status, stop, update
|
|
8
10
|
from .local import setup
|
|
9
11
|
from .token import token_group
|
|
@@ -11,8 +13,10 @@ from .token import token_group
|
|
|
11
13
|
# Re-exported: the command groups `arcsecond.cli` mounts.
|
|
12
14
|
__all__ = [
|
|
13
15
|
"backups",
|
|
16
|
+
"disks_group",
|
|
14
17
|
"doctor_cmd",
|
|
15
18
|
"db",
|
|
19
|
+
"license_group",
|
|
16
20
|
"setup",
|
|
17
21
|
"token_group",
|
|
18
22
|
"start",
|
|
@@ -231,6 +231,14 @@ ENV_KEYS: Dict[str, tuple] = {
|
|
|
231
231
|
"NASA GCN client credentials for the optional transient-alerts service. Empty until you paste yours.",
|
|
232
232
|
),
|
|
233
233
|
"GCN_CONSUMER_CLIENT_SECRET": (OPERATOR, "See GCN_CONSUMER_CLIENT_ID."),
|
|
234
|
+
"TOMORROW_IO_API_KEY": (
|
|
235
|
+
OPERATOR,
|
|
236
|
+
"Your own Tomorrow.io API key: the weather forecast, and the safety conditions only a forecast can feed "
|
|
237
|
+
"(cloud cover, humidity) where no station of yours measures them. A free key from "
|
|
238
|
+
"https://www.tomorrow.io/weather-api/ is enough; the backend asks once an hour per observing site. "
|
|
239
|
+
"Arcsecond's key is not shipped. Empty: no forecast, and the Safety strip says so. Asked at setup, or "
|
|
240
|
+
"`arcsecond setup --tomorrow-io-key KEY`.",
|
|
241
|
+
),
|
|
234
242
|
"FINK_ENABLED": (
|
|
235
243
|
BACKEND,
|
|
236
244
|
"`false` turns off the survey alerts from Fink in the optional transient-alerts service; GCN keeps "
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"""`arcsecond disks`: the disks of this machine Arcsecond.local can attach as
|
|
2
|
+
"Local Disk" storages.
|
|
3
|
+
|
|
4
|
+
The containers see nothing of the machine but the data folder, so a disk has
|
|
5
|
+
to be mounted into them before the web interface can attach a folder of it.
|
|
6
|
+
The CLI does that in a file of its own beside docker-compose.yml,
|
|
7
|
+
docker-compose.disks.yml, which it names to compose with the others (see
|
|
8
|
+
stack.compose_command): one bind mount per disk, at /disks/<name>, on the
|
|
9
|
+
services that read and write storages. The operator never edits it, nor .env.
|
|
10
|
+
|
|
11
|
+
`setup` and `update` ask once whether there is a disk to attach; the answer
|
|
12
|
+
"no" is remembered in .env (LOCAL_DISKS_ENV_KEY) so that the question is not
|
|
13
|
+
asked again. `arcsecond disks add/remove/list` change things afterwards.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import re
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Dict
|
|
21
|
+
|
|
22
|
+
import click
|
|
23
|
+
|
|
24
|
+
from arcsecond.errors import ArcsecondError
|
|
25
|
+
from arcsecond.options import basic_options
|
|
26
|
+
|
|
27
|
+
from . import stack
|
|
28
|
+
|
|
29
|
+
DISKS_COMPOSE_FILENAME = "docker-compose.disks.yml"
|
|
30
|
+
|
|
31
|
+
# Where the backend looks for disks (ARCSECOND_DISKS_ROOT backend-side).
|
|
32
|
+
DISKS_TARGET = "/disks"
|
|
33
|
+
|
|
34
|
+
# The services that read and write attached storages: the API (connection
|
|
35
|
+
# tests, folder browsing) and both workers (scans, pushes).
|
|
36
|
+
DISK_SERVICES = ("backend", "worker", "dataworker")
|
|
37
|
+
|
|
38
|
+
# "no" once the operator declined the question, so that `update` stops asking.
|
|
39
|
+
LOCAL_DISKS_ENV_KEY = "ARCSECOND_LOCAL_DISKS"
|
|
40
|
+
|
|
41
|
+
_NAME_RE = re.compile(r"[^a-z0-9._-]+")
|
|
42
|
+
_PAIR_RE = re.compile(r'source:\s*(".*")\s*\n\s*target:\s*/disks/([A-Za-z0-9._-]+)')
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def disks_compose_path(install) -> Path:
|
|
46
|
+
return install.path / DISKS_COMPOSE_FILENAME
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def disk_name(path: str, taken=()) -> str:
|
|
50
|
+
"""A name for /disks/<name>: the folder's own, lowercased, made safe, and
|
|
51
|
+
made unique among the names already taken."""
|
|
52
|
+
base = (
|
|
53
|
+
_NAME_RE.sub("-", Path(path.rstrip("/\\")).name.lower()).strip("-.") or "disk"
|
|
54
|
+
)
|
|
55
|
+
name, index = base, 2
|
|
56
|
+
while name in taken:
|
|
57
|
+
name, index = f"{base}-{index}", index + 1
|
|
58
|
+
return name
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _compose_quote(path: str) -> str:
|
|
62
|
+
# A JSON string is a YAML double-quoted scalar; `$` is compose's
|
|
63
|
+
# interpolation sign and doubles to stay literal.
|
|
64
|
+
return json.dumps(path.replace("$", "$$"))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def read_disks(install) -> Dict[str, str]:
|
|
68
|
+
"""{name: host path} of the disks mounted today, from the CLI's own file."""
|
|
69
|
+
path = disks_compose_path(install)
|
|
70
|
+
if not path.is_file():
|
|
71
|
+
return {}
|
|
72
|
+
disks = {}
|
|
73
|
+
for quoted, name in _PAIR_RE.findall(path.read_text(encoding="utf-8")):
|
|
74
|
+
try:
|
|
75
|
+
disks.setdefault(name, json.loads(quoted).replace("$$", "$"))
|
|
76
|
+
except ValueError:
|
|
77
|
+
continue
|
|
78
|
+
return disks
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def write_disks(install, disks: Dict[str, str]) -> None:
|
|
82
|
+
"""Rewrite docker-compose.disks.yml for these disks, or remove it when
|
|
83
|
+
there is none left."""
|
|
84
|
+
path = disks_compose_path(install)
|
|
85
|
+
if not disks:
|
|
86
|
+
if path.exists():
|
|
87
|
+
path.unlink()
|
|
88
|
+
return
|
|
89
|
+
lines = [
|
|
90
|
+
"# Written by `arcsecond disks`. Do not edit: run `arcsecond disks add PATH`",
|
|
91
|
+
"# or `arcsecond disks remove NAME` instead.",
|
|
92
|
+
"# The disks of this machine Arcsecond.local can attach as Local Disk storages.",
|
|
93
|
+
"services:",
|
|
94
|
+
]
|
|
95
|
+
for service in DISK_SERVICES:
|
|
96
|
+
lines += [f" {service}:", " volumes:"]
|
|
97
|
+
for name, source in sorted(disks.items()):
|
|
98
|
+
lines += [
|
|
99
|
+
" - type: bind",
|
|
100
|
+
f" source: {_compose_quote(source)}",
|
|
101
|
+
f" target: {DISKS_TARGET}/{name}",
|
|
102
|
+
]
|
|
103
|
+
path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def add_disk(install, path: str, name: str = None) -> str:
|
|
107
|
+
"""Add a disk; answers the name it is mounted under."""
|
|
108
|
+
from .local import expand_path
|
|
109
|
+
|
|
110
|
+
source = expand_path(path.strip())
|
|
111
|
+
if not Path(source).is_dir():
|
|
112
|
+
raise ArcsecondError(f"{source} is not a folder of this machine.")
|
|
113
|
+
disks = read_disks(install)
|
|
114
|
+
for existing_name, existing_source in disks.items():
|
|
115
|
+
if existing_source == source:
|
|
116
|
+
return existing_name
|
|
117
|
+
if name:
|
|
118
|
+
name = _NAME_RE.sub("-", name.lower()).strip("-.")
|
|
119
|
+
if not name:
|
|
120
|
+
raise ArcsecondError(
|
|
121
|
+
"A disk name holds letters, digits, dots, dashes or underscores."
|
|
122
|
+
)
|
|
123
|
+
if name in disks:
|
|
124
|
+
raise ArcsecondError(
|
|
125
|
+
f"A disk is already mounted as {name}. `arcsecond disks list` shows them."
|
|
126
|
+
)
|
|
127
|
+
else:
|
|
128
|
+
name = disk_name(source, taken=disks.keys())
|
|
129
|
+
disks[name] = source
|
|
130
|
+
write_disks(install, disks)
|
|
131
|
+
return name
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _record_declined(install) -> None:
|
|
135
|
+
from .local import _parse_env_keys
|
|
136
|
+
|
|
137
|
+
env_path = install.env_path
|
|
138
|
+
lines = (
|
|
139
|
+
env_path.read_text(encoding="utf-8").splitlines() if env_path.exists() else []
|
|
140
|
+
)
|
|
141
|
+
if LOCAL_DISKS_ENV_KEY in _parse_env_keys(lines):
|
|
142
|
+
return
|
|
143
|
+
if lines and lines[-1].strip():
|
|
144
|
+
lines.append("")
|
|
145
|
+
lines += [
|
|
146
|
+
"# `no`: setup and update no longer ask for disks to attach. `arcsecond disks add PATH` still does.",
|
|
147
|
+
f"{LOCAL_DISKS_ENV_KEY}=no",
|
|
148
|
+
]
|
|
149
|
+
env_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def offer_disks(install) -> bool:
|
|
153
|
+
"""The question `setup` and `update` ask once: is there a disk of this
|
|
154
|
+
machine to attach? True when the disks changed."""
|
|
155
|
+
if (
|
|
156
|
+
read_disks(install)
|
|
157
|
+
or install.read_env(LOCAL_DISKS_ENV_KEY)
|
|
158
|
+
or not sys.stdin.isatty()
|
|
159
|
+
):
|
|
160
|
+
return False
|
|
161
|
+
click.echo(
|
|
162
|
+
'\nArcsecond.local can index data already on a disk of this machine (a "Local Disk" storage,'
|
|
163
|
+
"\nattached in the web interface), without copying it."
|
|
164
|
+
)
|
|
165
|
+
if not click.confirm(
|
|
166
|
+
"Is there a disk or folder of this machine to make available?", default=False
|
|
167
|
+
):
|
|
168
|
+
_record_declined(install)
|
|
169
|
+
return False
|
|
170
|
+
changed = False
|
|
171
|
+
while True:
|
|
172
|
+
path = click.prompt(
|
|
173
|
+
"Path of the disk or folder (empty when done)",
|
|
174
|
+
default="",
|
|
175
|
+
show_default=False,
|
|
176
|
+
).strip()
|
|
177
|
+
if not path:
|
|
178
|
+
return changed
|
|
179
|
+
try:
|
|
180
|
+
name = add_disk(install, path)
|
|
181
|
+
except ArcsecondError as e:
|
|
182
|
+
click.echo(click.style(str(e), fg="red"))
|
|
183
|
+
continue
|
|
184
|
+
changed = True
|
|
185
|
+
click.echo(
|
|
186
|
+
click.style(
|
|
187
|
+
f" {path} will be available as {DISKS_TARGET}/{name}.", fg="green"
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
# --- Commands ---------------------------------------------------------------
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _apply(install, restart: bool) -> None:
|
|
196
|
+
if not restart:
|
|
197
|
+
click.echo(
|
|
198
|
+
"Run `arcsecond restart backend worker dataworker` to make the change effective."
|
|
199
|
+
)
|
|
200
|
+
return
|
|
201
|
+
from .lifecycle import _streamed
|
|
202
|
+
|
|
203
|
+
stack.ensure_docker()
|
|
204
|
+
click.echo("Recreating the services that read storages ...")
|
|
205
|
+
_streamed(
|
|
206
|
+
install, "docker compose up", "up", "-d", "--force-recreate", *DISK_SERVICES
|
|
207
|
+
)
|
|
208
|
+
click.echo(click.style("Done.", fg="green"))
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
_dir_option = click.option(
|
|
212
|
+
"--dir",
|
|
213
|
+
"directory",
|
|
214
|
+
default=None,
|
|
215
|
+
metavar="FOLDER",
|
|
216
|
+
help="The Arcsecond.local folder (the one holding docker-compose.yml). "
|
|
217
|
+
"Default: the current folder, else the one `arcsecond setup` last ran in.",
|
|
218
|
+
)
|
|
219
|
+
_no_restart_option = click.option(
|
|
220
|
+
"--no-restart", is_flag=True, help="Change the configuration only; restart later."
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@click.group(
|
|
225
|
+
name="disks", short_help="Disks of this machine to attach as Local Disk storages."
|
|
226
|
+
)
|
|
227
|
+
def disks_group():
|
|
228
|
+
"""The disks (or folders) of this machine Arcsecond.local can attach as
|
|
229
|
+
Local Disk storages. Once added here, attach a folder of one in the web
|
|
230
|
+
interface: Attached Storages, New Storage, Local Disk."""
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@disks_group.command(name="list", help="List the disks made available.")
|
|
234
|
+
@_dir_option
|
|
235
|
+
@basic_options
|
|
236
|
+
def disks_list(directory):
|
|
237
|
+
install = stack.resolve_install_dir(directory)
|
|
238
|
+
disks = read_disks(install)
|
|
239
|
+
if not disks:
|
|
240
|
+
click.echo("No disk yet. Add one with: arcsecond disks add PATH")
|
|
241
|
+
return
|
|
242
|
+
for name, source in sorted(disks.items()):
|
|
243
|
+
click.echo(
|
|
244
|
+
f" {click.style(name, bold=True)} {source} (seen as {DISKS_TARGET}/{name})"
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@disks_group.command(
|
|
249
|
+
name="add", help="Make a disk or folder of this machine available."
|
|
250
|
+
)
|
|
251
|
+
@click.argument("path")
|
|
252
|
+
@click.option(
|
|
253
|
+
"--name",
|
|
254
|
+
default=None,
|
|
255
|
+
help="The name it is listed under. Default: the folder's name.",
|
|
256
|
+
)
|
|
257
|
+
@_dir_option
|
|
258
|
+
@_no_restart_option
|
|
259
|
+
@basic_options
|
|
260
|
+
def disks_add(path, name, directory, no_restart):
|
|
261
|
+
install = stack.resolve_install_dir(directory)
|
|
262
|
+
before = read_disks(install)
|
|
263
|
+
name = add_disk(install, path, name)
|
|
264
|
+
if read_disks(install) == before:
|
|
265
|
+
click.echo(f"{path} is already available as {name}.")
|
|
266
|
+
return
|
|
267
|
+
click.echo(f"{path} is available as {click.style(name, bold=True)}.")
|
|
268
|
+
_apply(install, restart=not no_restart)
|
|
269
|
+
click.echo(
|
|
270
|
+
"Attach a folder of it in the web interface: Attached Storages, New Storage, Local Disk."
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
@disks_group.command(name="remove", help="Stop making a disk available.")
|
|
275
|
+
@click.argument("name")
|
|
276
|
+
@_dir_option
|
|
277
|
+
@_no_restart_option
|
|
278
|
+
@basic_options
|
|
279
|
+
def disks_remove(name, directory, no_restart):
|
|
280
|
+
install = stack.resolve_install_dir(directory)
|
|
281
|
+
disks = read_disks(install)
|
|
282
|
+
if name not in disks:
|
|
283
|
+
raise ArcsecondError(
|
|
284
|
+
f"No disk named {name}. `arcsecond disks list` shows them."
|
|
285
|
+
)
|
|
286
|
+
del disks[name]
|
|
287
|
+
write_disks(install, disks)
|
|
288
|
+
click.echo(
|
|
289
|
+
f"{name} removed. Local Disk storages attached from it can no longer be read; "
|
|
290
|
+
"detach them in the web interface."
|
|
291
|
+
)
|
|
292
|
+
_apply(install, restart=not no_restart)
|
|
@@ -50,7 +50,7 @@ from arcsecond.api.config import ArcsecondConfig
|
|
|
50
50
|
from arcsecond.errors import ArcsecondError
|
|
51
51
|
from arcsecond.options import basic_options
|
|
52
52
|
|
|
53
|
-
from . import stack
|
|
53
|
+
from . import forecast, stack
|
|
54
54
|
from .lifecycle import dir_option
|
|
55
55
|
from .local import (
|
|
56
56
|
FRONTEND_HOST_ENV_KEY,
|
|
@@ -335,6 +335,21 @@ def check_env_file(install) -> List[Finding]:
|
|
|
335
335
|
return findings
|
|
336
336
|
|
|
337
337
|
|
|
338
|
+
def check_forecast_key(install) -> Finding:
|
|
339
|
+
"""Present or not: whether the key works would cost a metered call."""
|
|
340
|
+
if (install.read_env(forecast.ENV_KEY) or "").strip():
|
|
341
|
+
return Finding(
|
|
342
|
+
"forecast.key", "Weather forecast key", OK, "a Tomorrow.io key is set"
|
|
343
|
+
)
|
|
344
|
+
return Finding(
|
|
345
|
+
"forecast.key",
|
|
346
|
+
"Weather forecast key",
|
|
347
|
+
WARN,
|
|
348
|
+
"no Tomorrow.io key: no weather forecast, and no safety condition fed by it",
|
|
349
|
+
fix=forecast.LATER,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
|
|
338
353
|
def check_lan_host(install, host: Host) -> Finding:
|
|
339
354
|
declared = (install.read_env(FRONTEND_HOST_ENV_KEY) or "").strip()
|
|
340
355
|
lan = host.lan_ipv4()
|
|
@@ -788,6 +803,7 @@ def run_checks(
|
|
|
788
803
|
findings.append(docker)
|
|
789
804
|
findings.append(check_template(install))
|
|
790
805
|
findings += check_env_file(install)
|
|
806
|
+
findings.append(check_forecast_key(install))
|
|
791
807
|
findings.append(check_lan_host(install, host))
|
|
792
808
|
|
|
793
809
|
running = False
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""The installation's own Tomorrow.io key.
|
|
2
|
+
|
|
3
|
+
The backend asks Tomorrow.io for each observing site's current conditions
|
|
4
|
+
once an hour, and for the forecast the web app shows. The key is the
|
|
5
|
+
observatory's own: Arcsecond's is not shipped with the images, and an
|
|
6
|
+
installation without one simply has no forecast (the safety strip says so
|
|
7
|
+
for any condition only the forecast could have fed). A free key carries
|
|
8
|
+
about twenty sites at the hourly beat.
|
|
9
|
+
|
|
10
|
+
`arcsecond setup` asks for it while the TOMORROW_IO_API_KEY line of .env is
|
|
11
|
+
empty, the way it asks for the access token: an empty answer is "later", not
|
|
12
|
+
"never", since nothing is lost by asking again.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import click
|
|
16
|
+
|
|
17
|
+
from .utils import _read_env_value, _set_env_value
|
|
18
|
+
|
|
19
|
+
ENV_KEY = "TOMORROW_IO_API_KEY"
|
|
20
|
+
SIGN_UP_URL = "https://www.tomorrow.io/weather-api/"
|
|
21
|
+
|
|
22
|
+
ENV_COMMENT = (
|
|
23
|
+
"# Your own Tomorrow.io API key (optional — the weather forecast and the"
|
|
24
|
+
f" safety conditions it feeds). A free key is enough: {SIGN_UP_URL}"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
LATER = "arcsecond setup --tomorrow-io-key <your key> && arcsecond restart"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def has_key(env_path) -> bool:
|
|
31
|
+
return bool((_read_env_value(ENV_KEY, env_path) or "").strip())
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def offer(env_path, key=None, interactive=True) -> None:
|
|
35
|
+
"""Record ``key`` (--tomorrow-io-key) when given; otherwise ask while
|
|
36
|
+
none is recorded and there is a terminal to ask on."""
|
|
37
|
+
if key is not None:
|
|
38
|
+
key = key.strip()
|
|
39
|
+
_set_env_value(env_path, ENV_KEY, key)
|
|
40
|
+
if key:
|
|
41
|
+
click.echo(
|
|
42
|
+
"Tomorrow.io key recorded. The weather forecast starts with the next arcsecond restart."
|
|
43
|
+
)
|
|
44
|
+
else:
|
|
45
|
+
click.echo(
|
|
46
|
+
"Tomorrow.io key removed: this installation has no weather forecast."
|
|
47
|
+
)
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
if has_key(env_path) or not interactive:
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
click.echo(
|
|
54
|
+
"\nThe weather forecast comes from Tomorrow.io, with a key of your own "
|
|
55
|
+
f"(a free one is enough: {SIGN_UP_URL})."
|
|
56
|
+
)
|
|
57
|
+
entered = click.prompt(
|
|
58
|
+
"Tomorrow.io API key (nothing is shown while you type; leave it empty to do this later)",
|
|
59
|
+
hide_input=True,
|
|
60
|
+
default="",
|
|
61
|
+
show_default=False,
|
|
62
|
+
).strip()
|
|
63
|
+
if entered:
|
|
64
|
+
_set_env_value(env_path, ENV_KEY, entered)
|
|
65
|
+
click.echo(click.style("Tomorrow.io key recorded.", fg="green"))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def next_step(env_path):
|
|
69
|
+
"""The line `setup` ends with when there is still no key, or None."""
|
|
70
|
+
if has_key(env_path):
|
|
71
|
+
return None
|
|
72
|
+
return (
|
|
73
|
+
"No Tomorrow.io key yet, so no weather forecast. With a key of your own "
|
|
74
|
+
f"({SIGN_UP_URL}): {LATER}"
|
|
75
|
+
)
|