Skip to content

Commit 0c241da

Browse files
authored
Merge branch 'develop' into u/tjr/terraform
2 parents bb8559d + 25324ab commit 0c241da

File tree

352 files changed

+26005
-15553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

352 files changed

+26005
-15553
lines changed

.github/workflows/BrokerTest.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Test Broker
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
push:
7+
8+
env:
9+
PYTHON_VERSION: 3.11
10+
11+
jobs:
12+
discover:
13+
name: Discover Microservices
14+
runs-on: ubuntu-latest
15+
16+
outputs:
17+
matrix: ${{ steps.find_tests.outputs.matrix }}
18+
19+
steps:
20+
- name: Checkout source
21+
uses: actions/checkout@v4
22+
23+
- name: Find testable apps
24+
id: find_tests
25+
run: |
26+
# Find application directories containing a 'tests' subdirectory nd format the result as JSON
27+
test_dirs=$(find broker/cloud_functions -type d -name "tests" -exec dirname {} \; | jq -R . | jq -s . | tr -d '\n')
28+
echo "found $test_dirs"
29+
echo "matrix={\"app_dir\":$test_dirs}" >> $GITHUB_OUTPUT
30+
31+
test:
32+
name: Test Microservices
33+
runs-on: ubuntu-latest
34+
needs: [ discover ]
35+
36+
strategy:
37+
fail-fast: false
38+
matrix: ${{ fromJSON(needs.discover.outputs.matrix) }}
39+
40+
steps:
41+
- name: Checkout source
42+
uses: actions/checkout@v4
43+
44+
- name: Setup Python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: ${{ env.PYTHON_VERSION }}
48+
49+
- name: Install dependencies
50+
run: |
51+
pip install coverage
52+
pip install -r ${{ matrix.app_dir }}/requirements.txt
53+
54+
- name: Test ${{ matrix.app_dir }} app
55+
run: coverage run -m unittest discover ${{ matrix.app_dir }}
56+
57+
report-status:
58+
name: Report Test Status
59+
if: always()
60+
needs: [ test ]
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- name: Check build status
65+
if: ${{ contains(needs.*.result, 'failure') }}
66+
run: exit 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pitt-reader.user.keytab
1313

1414
# IDE files
1515
.idea/
16+
.vscode/
1617

1718
# Byte-compiled / optimized / DLL files
1819
__pycache__/

.readthedocs.yml renamed to .readthedocs.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
# Required
55
version: 2
66

7+
# Set the OS, Python version and other tools you might need
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.12"
12+
713
# Build documentation in the docs/ directory with Sphinx
814
sphinx:
915
configuration: docs/source/conf.py
@@ -13,10 +19,5 @@ formats: []
1319

1420
# Set the version of Python and requirements required to build the docs
1521
python:
16-
version: 3.7
17-
system_packages: true
1822
install:
1923
- requirements: docs/requirements.txt
20-
- method: setuptools
21-
path: .
22-

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
@@ -10,4 +11,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1011
## [0.6.0] - 2021-00-00
1112

1213
### Changed
13-
- Creates a "Working Notes" section in RTD and moves the following directories there: notes/, version_tracking/, troy/ (from the `troy` branch).
14+
15+
- Creates a "Working Notes" section in RTD and moves the following directories there:
16+
notes/, version_tracking/, troy/ (from the `troy` branch).

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
[![python](https://img.shields.io/badge/python-3.7-g.svg)]()
2-
[![Build Status](https://travis-ci.com/mwvgroup/Pitt-Google-Broker.svg?branch=master)](https://travis-ci.com/mwvgroup/Pitt-Google-Broker)
3-
[![Documentation Status](https://readthedocs.org/projects/pitt-broker/badge/?version=latest)](https://pitt-broker.readthedocs.io/en/latest/?badge=latest)
4-
51
# Pitt-Google Alert Broker
62

7-
The Pitt-Google broker is an astronomical alert broker that is being developed for large scale surveys of the night sky, particularly the upcoming [Vera Rubin Observatory's Legacy Survey of Space and Time](https://www.lsst.org/) (LSST).
8-
We currently process and serve the [Zwicky Transient Facility](https://www.ztf.caltech.edu/)'s (ZTF) nightly alert stream.
3+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/93e282e9d5784de6a46e6b87ab6d0afa)](https://app.codacy.com/gh/mwvgroup/Pitt-Google-Broker/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
4+
[![Documentation Status](https://readthedocs.org/projects/pitt-broker/badge/?version=latest)](https://pitt-broker.readthedocs.io/en/latest/?badge=latest)
5+
6+
The Pitt-Google broker is an astronomical alert broker that is being developed
7+
for large scale surveys of the night sky, particularly the upcoming
8+
[Vera Rubin Observatory's Legacy Survey of Space and Time](https://www.lsst.org/) (LSST).
9+
We currently process and serve the [Zwicky Transient Facility](https://www.ztf.caltech.edu/)'s
10+
(ZTF) nightly alert stream.
911
The broker runs on the [Google Cloud Platform](https://cloud.google.com) (GCP).
1012

1113
Documentation is at [pitt-broker.readthedocs.io](https://pitt-broker.readthedocs.io/).
1214

13-
If you run into issues or need assistance, please [open an Issue](https://github.com/mwvgroup/Pitt-Google-Broker/issues).
15+
If you run into issues or need assistance, please
16+
[open an Issue](https://github.com/mwvgroup/Pitt-Google-Broker/issues).

broker/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
import os
99
from warnings import warn
1010

11-
if 'PGB_OFFLINE' not in os.environ:
11+
if "PGB_OFFLINE" not in os.environ:
1212
from google.cloud import logging as cloud_logging
1313

1414
cloud_logging.Client().setup_logging()
1515

16-
for _var in ('GOOGLE_CLOUD_PROJECT', 'GOOGLE_APPLICATION_CREDENTIALS'):
16+
for _var in ("GOOGLE_CLOUD_PROJECT", "GOOGLE_APPLICATION_CREDENTIALS"):
1717
if _var not in os.environ:
1818
warn(
19-
f'Environmental variable ``{_var}`` not found. '
20-
f'Some package functionality may not be available.'
19+
f"Environmental variable ``{_var}`` not found. "
20+
f"Some package functionality may not be available."
2121
)
2222

23-
__version__ = 'development'
23+
__version__ = "development"

broker/broker_utils/CHANGELOG.md

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# Changelog<a name="changelog"></a>
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6+
7+
<!-- uncomment the following when we're out of alpha and actually following it -->
8+
9+
<!-- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -->
10+
11+
## \[Unreleased\]<a name="unreleased"></a>
12+
13+
## \[0.2.47\] - 2023-06-20
14+
15+
### Changed
16+
- `broker_utils/avro_schemas` now contains the alert schemas and broker classification schema for ELAsTiCC schema version 0.9.1
17+
- `avro_schemas/load.py` registers ELAsTiCC schema version 0.9.1
18+
- Improve error handling and logging in `data_utils.open_alert`. The function uses a lot of
19+
broad try/excepts in a brute-force attempt to open an alert packet that could be in many
20+
different formats. These changes do some moderate clean up of the error handling and
21+
provide more detail in the logs about a known issue with some versions of fastavro.
22+
- Sort all imports.
23+
- Cleanup syntax issues identified by Codacy.
24+
25+
### Fixed
26+
27+
- Bugfix the IDs in `testing.Mock`.
28+
29+
## \[0.2.46\] - 2023-04-09
30+
31+
### Changed
32+
33+
- Alert filename "objectId.sourceId.topic.avro" -> "topic/objectId/sourceId.avro"
34+
35+
## \[0.2.45\] - 2022-10-22
36+
37+
### Fixed
38+
39+
- Import `pandas` for `data_utils.alert_lite_to_dataframe()`.
40+
- Remove the `xmatch` dict from the dataframe created by `data_utils.alert_lite_to_dataframe()`.
41+
42+
## \[0.2.44\] - 2022-10-20
43+
44+
### Added
45+
46+
- `data_utils.alert_lite_to_dataframe()`
47+
48+
## \[0.2.43\] - 2022-08-25
49+
50+
### Fixed
51+
52+
- Updates `data_utils.open_alert()` to properly handle json-serialized alerts in a Cloud Function.
53+
54+
## \[0.2.42\] - 2022-08-24
55+
56+
### Fixed
57+
58+
- Fix bug introduced by allowing `data_utils.open_alert()` to blindly send `**kwargs` to the
59+
functions it calls. `data_utils.open_alert()` now sends only the arguments that are appropriate
60+
for the function it's calling.
61+
62+
## \[0.2.41\] - 2022-08-19
63+
64+
### Fixed
65+
66+
- Fix bug preventing data files from being included with the package.
67+
68+
## \[0.2.40\] - 2022-08-19
69+
70+
### Added
71+
72+
- `avro_schemas` module to handle schemaless alerts. Includes schema data files.
73+
- `data_utils.open_alert()` which uses a brute-force strategy to try to open alerts of all
74+
different formats.
75+
76+
### Changed
77+
78+
- In `data_utils`, deprecate functions `load_alert()` and `decode_alert()` in favor of
79+
`open_alert()`
80+
81+
## \[0.2.39\] - 2022-06-23
82+
83+
### Fixed
84+
85+
- Bug fix: don't use `dataclasses.dataclass` decorator on `collections.namedtuple` modules.
86+
87+
## \[0.2.38\] - 2022-06-23
88+
89+
### Added
90+
91+
- Use `dataclasses.dataclass` decorator on `types` and `testing` modules
92+
93+
### Fixed
94+
95+
- Bug fix in `types.AlertIds.extract_ids()`: access `self.id_keys` as a property, not a function call.
96+
97+
## \[0.2.37\] - 2022-06-21
98+
99+
### Changed
100+
101+
- Minor internal improvements and bug fixes to `testing`.
102+
- Rename attributes `testing.Mock.results` to `testing.Mock.module_results` and
103+
`testing.TestAlert.publish_as` to `testing.TestAlert.serialize`.
104+
105+
## \[0.2.36\] - 2022-06-20
106+
107+
### Added
108+
109+
- Adds `mock` as a keyword argument in `testing.TestAlert`.
110+
111+
## \[0.2.35\] - 2022-06-20
112+
113+
### Added
114+
115+
- `types` module containing `_AlertIds`, `AlertIds`, and `AlertFilename`. These were rewritten and
116+
moved out of `data_utils`.
117+
118+
### Changed
119+
120+
- Lazy load `pandas`. It hogs memory on Cloud Functions.
121+
- Remove `data_utils.AlertIds`, `data_utils.idUtils`, and `data_utils.AlertFilename`. They moved to
122+
the new `types` module.
123+
- Rename `tests` module to `testing` and rewrite the included classes to give them more
124+
functionality and make them easier to use.
125+
126+
## \[0.2.34\] - 2022-06-17
127+
128+
### Added
129+
130+
- add `AlertFilename` class in `data_utils`
131+
132+
### Changed
133+
134+
- updated `tests.TestValidator` to accept keyword argument `ids_in` that determines whether
135+
alert IDs are extracted from message attributes or the Avro filename.
136+
137+
## \[0.2.33\] - 2022-06-17
138+
139+
### Added
140+
141+
- add "kafka.topic" to mocked msg attributes in `tests.TestAlert`
142+
143+
## \[0.2.32\] - 2022-05-19
144+
145+
### Changed
146+
147+
- fix bug when creating avro payload in `tests.TestAlert`
148+
149+
## \[0.2.31\] - 2022-05-19
150+
151+
### Added
152+
153+
- `tests` module and `tests.TestValidator` class
154+
- `data_utils.idUtils` class
155+
156+
### Changed
157+
158+
- moved `data_utils.TestAlert` to `tests.TestAlert`
159+
160+
## \[0.2.30\] - 2022-05-18
161+
162+
### Added
163+
164+
- `data_utils.AlertIds` and `data_utils.TestAlert`
165+
- `gcp_utils.purge_subscription()`
166+
167+
## \[0.2.29\] - 2022-05-17
168+
169+
### Added
170+
171+
- `schema_maps.get_key()` return the key name or the final element in the list corresponding to a
172+
schema map and key.
173+
- `schema_maps.get_value()` return the alert value corresponding to a schema map and key.
174+
175+
### Changed
176+
177+
- Modules updated to use the added functions.
178+
- `data_utils.load_yaml()` moved to `schema_maps.load_yaml()` to avoid circular imports.
179+
180+
## \[0.2.28\] - 2022-03-27
181+
182+
### Added
183+
184+
- `math` module - new home for math functions (currently `jd_to_mjd` and `mag_to_flux`)
185+
- `data_utils.load_yaml`
186+
187+
### Changed
188+
189+
- Move functions `jd_to_mjd` and `mag_to_flux` from `data_utils` to the new `math` module. Update
190+
SuperNNova Cloud Function to accommodate (outside `broker_utils` at
191+
broker/cloud_functions/classify_snn).
192+
- Update `schema_maps.load_schema_map` to accept a Path and load from a local file
193+
194+
### Removed
195+
196+
- `data_utils._get_schema_map`
197+
198+
## \[0.2.27\] - 2022-03-26
199+
200+
### Added<a name="added-1"></a>
201+
202+
- `data_utils._get_schema_map` function to load schema map from file if needed and check that it
203+
is a dict.
204+
- `data_utils.load_alert` to load an alert from file.
205+
- Support for passing `alert_avro` as a path to `data_utils.decode_alert`.
206+
207+
### Changed<a name="changed-1"></a>
208+
209+
- `data_utils` now passes `schema_map` and `drop_cutouts` as kwargs.
210+
211+
### Fixed<a name="fixed-1"></a>
212+
213+
- Rename variable `pgb_project_id` to `PROJECT_ID`.
214+
215+
## \[0.2.26\] - 2022-03-26<a name="0226---2022-03-26"></a>
216+
217+
### Added<a name="added"></a>
218+
219+
- Add `project_id` as a kwarg to `gcp_utils` bigquery functions.
220+
221+
### Changed<a name="changed"></a>
222+
223+
- Set GCP project ID by an environment variable, fall back to the production broker project.
224+
Formerly this was hardcoded to production project.
225+
- Unpin `numpy`
226+
- Unpin `google.cloud.bigquery`
227+
- Unpin `google.cloud.pubsub`. Update `consumer_sim` and `gcp_utils` to accommodate.

broker/broker_utils/MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
include requirements.txt
2+
include requirements_pinned.txt
3+
include broker_utils/avro_schemas/*.avsc

broker/broker_utils/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
Note that the schema maps are stored in a Cloud Storage bucket and are not packaged with this module.
77
This has the following benefits:
8+
89
1. Schema maps can be updated easily by uploading new files to the bucket.
910
2. Broker instances can use different schema maps; each instance loads them from their own `broker_files` bucket.

0 commit comments

Comments
 (0)