-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lsst-dm/u/ktl/initial
Initial repo and CSC setup.
- Loading branch information
Showing
14 changed files
with
267 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,7 @@ pytest_session.txt | |
.cache/ | ||
.pytest_cache | ||
.coverage | ||
.pre-commit-config.yaml | ||
.flake8 | ||
.isort.cfg | ||
.mypy.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
check-yaml: true | ||
check-xml: true | ||
black: true | ||
flake8: true | ||
isort: true | ||
mypy: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Copyright 2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
Copyright 2023 The Board of Trustees of the Leland Stanford Junior University, through SLAC National Accelerator Laboratory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@Library('JenkinsShared')_ | ||
DevelopPipeline(name: "consdb", module_name: "lsst.consdb", idl_names: ["ConsDB"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@Library('JenkinsShared')_ | ||
CondaPipeline(["consdb_config"], "consdb", "lsst.consdb") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{% set data= load_setup_py_data() %} | ||
package: | ||
name: consdb | ||
version: {{ data.get('version') }} | ||
|
||
source: | ||
path: ../ | ||
|
||
build: | ||
noarch: python | ||
script: {{ PYTHON }} -m pip install --no-deps --ignore-installed . | ||
script_env: | ||
- PATH | ||
- PYTHONPATH | ||
- LD_LIBRARY_PATH | ||
- OSPL_HOME | ||
- PYTHON_BUILD_VERSION | ||
- PYTHON_BUILD_LOCATION | ||
- LSST_DDS_DOMAIN | ||
# Replace with csc configuration repo directory, i.e. TS_CONFIG_ATTCS_DIR for athexapod | ||
|
||
test: | ||
requires: | ||
- ts-conda-build | ||
- ts-dds | ||
- ts-idl {{ idl_version }} | ||
- ts-salobj {{ salobj_version }} | ||
source_files: | ||
- python | ||
- bin | ||
- tests | ||
- schema | ||
- setup.cfg | ||
- pyproject.toml | ||
commands: | ||
- pytest | ||
|
||
requirements: | ||
host: | ||
- python {{ python }} | ||
- pip | ||
- setuptools_scm | ||
- setuptools | ||
- pytest-runner | ||
build: | ||
- python {{ python }} | ||
- setuptools_scm | ||
- setuptools | ||
- ts-conda-build =0.3 | ||
run: | ||
- python {{ python }} | ||
- setuptools | ||
- setuptools_scm | ||
- ts-salobj | ||
- ts-idl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[build-system] | ||
requires = ["setuptools>=45", "setuptools-scm[toml]>=6.2"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "consdb" | ||
description = "consdb is a Commandable SAL Component for the `Vera C. Rubin Observatory <https://lsst.org>`_." | ||
license = { text = "GPL" } | ||
dependencies = ["pymodbus"] | ||
readme = "README.rst" | ||
urls = { documentation = "https://consdb.lsst.io", source_code = "https://github.com/lsst-dm/consdb"} | ||
dynamic = ["version"] | ||
|
||
[tool.setuptools.dynamic] | ||
version = { attr = "setuptools_scm.get_version" } | ||
|
||
[tool.setuptools.packages.find] | ||
where = [ "python" ] | ||
|
||
[project.scripts] | ||
run_consdb = "lsst.consdb.cli:execute_csc" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "python/lsst/consdb/version.py" | ||
write_to_template = """ | ||
# Generated by setuptools_scm | ||
__all__ = ["__version__"] | ||
__version__ = "{version}" | ||
""" | ||
|
||
[tool.pytest.ini_options] | ||
log_level = "DEBUG" | ||
asyncio_mode = "auto" | ||
|
||
[project.optional-dependencies] | ||
dev = ["pytest"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# This file is part of consdb. | ||
# | ||
# Developed for the LSST Telescope and Site Systems. | ||
# This product includes software developed by the LSST Project | ||
# (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
__all__ = ["ConsDB", "run_consdb"] | ||
|
||
import asyncio | ||
import types | ||
|
||
import yaml | ||
from lsst.ts import salobj | ||
|
||
from . import __version__ | ||
|
||
CONFIG_SCHEMA = yaml.safe_load( | ||
""" | ||
$schema: http://json-schema.org/draft-07/schema# | ||
$id: https://github.com/lsst/consdb/blob/main/schema/ConsDB.yaml | ||
title: ConsDB v1 | ||
Description: Schema for ConsDB configuration files | ||
type: object | ||
properties: | ||
instances: | ||
type: array | ||
description: Configuration for each trigger event | ||
minItem: 1 | ||
items: | ||
type: object | ||
properties: | ||
trigger: | ||
type: string | ||
description: name of SAL event to trigger on | ||
tables: | ||
type: array | ||
description: List of ConsDB tables to update | ||
minItem: 1 | ||
items: | ||
type: object | ||
properties: | ||
table: | ||
type: string | ||
description: ConsDB table to insert/update | ||
key: | ||
type: string | ||
description: Name of primary key column in ConsDB table | ||
columns: | ||
type: array | ||
description: List of ConsDB columns to insert/update | ||
minItem: 1 | ||
items: | ||
type: object | ||
properties: | ||
column: | ||
type: string | ||
description: Name of ConsDB column to insert/update | ||
query: | ||
type: string | ||
description: EFD query to execute | ||
required: | ||
- column | ||
- query | ||
additionalProperties: false | ||
required: | ||
- table | ||
- columns | ||
additionalProperties: false | ||
required: | ||
- trigger | ||
- tables | ||
additionalProperties: false | ||
""" | ||
) | ||
|
||
|
||
class ConsDB(salobj.ConfigurableCsc): | ||
"""CSC to populate the Consolidated Database. | ||
Parameters | ||
---------- | ||
config_dir: `str`, optional | ||
Directory of configuration files (for unit testing). | ||
initial_state: `salobj.State`, optional | ||
The initial state of the CSC. This is provided for unit testing. | ||
override: `str`, optional | ||
Configuration override file to appliy if ``initial_state`` is | ||
`salobj.State.DISABLED` or `salobj.State.ENABLED`. | ||
simulation_mode: `int` (optional) | ||
Simulation mode (default = 0, do not simulate). | ||
Raises | ||
------ | ||
ValueError | ||
If ``config_dir`` is not a directory or ``initial_state`` is invalid. | ||
salobj.ExpectedError | ||
If ``simulation_mode`` is invalid. | ||
""" | ||
|
||
valid_simulation_modes = (0, 1) | ||
version = __version__ | ||
|
||
def __init__( | ||
self, | ||
config_dir: str | None = None, | ||
initial_state: salobj.State = salobj.State.STANDBY, | ||
override: str = "", | ||
simulation_mode: int = 0, | ||
): | ||
super().__init__( | ||
"ConsDB", | ||
index=None, | ||
config_schema=CONFIG_SCHEMA, | ||
config_dir=config_dir, | ||
initial_state=initial_state, | ||
override=override, | ||
simulation_mode=simulation_mode, | ||
) | ||
|
||
@classmethod | ||
def get_config_pkg(cls) -> str: | ||
return "consdb_config" | ||
|
||
async def configure(self, config: types.SimpleNamespace) -> None: | ||
pass | ||
|
||
async def handle_summary_state(self) -> None: | ||
pass | ||
|
||
|
||
def run_consdb() -> None: | ||
"""Run the ConsDB CSC.""" | ||
asyncio.run(ConsDB.amain()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import setuptools | ||
import setuptools_scm | ||
|
||
setuptools.setup(version=setuptools_scm.get_version()) |