-
Notifications
You must be signed in to change notification settings - Fork 0
DM-34134: Reintegrate activator with upload.py #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a435d84
Add unit tests for Visit.
kfindeisen a0284a0
Document next_visit_handler.
kfindeisen f9ab36b
Distinguish instrument names in activator.py.
kfindeisen c1478fe
Turn off bad default skymap.
kfindeisen c32d5e5
Fix bug in local repo initialization.
kfindeisen ee36814
Fix initialization bug in MiddlewareInterface.
kfindeisen de02f82
Add diagnostic info to gatekeeper assert.
kfindeisen 557c29c
Generate pgpass file in service container.
kfindeisen 8ab663d
Move DB addresses to environment.
kfindeisen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,58 @@ | ||
# This file is part of prompt_prototype. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# 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__ = ["make_pgpass"] | ||
|
||
|
||
import os | ||
import stat | ||
|
||
|
||
PSQL_DB = "postgres" | ||
PSQL_USER = "postgres" | ||
|
||
|
||
def make_pgpass(): | ||
"""Create a .pgpass file that contains the service's database credentials. | ||
|
||
This function is designed to work in the Prompt Processing Service's docker | ||
container, and no other environment. | ||
|
||
Raises | ||
------ | ||
RuntimeError | ||
Raised if the database passwords cannot be found. | ||
""" | ||
try: | ||
ip_apdb = os.environ["IP_APDB"] | ||
pass_apdb = os.environ["PSQL_APDB_PASS"] | ||
ip_registry = os.environ["IP_REGISTRY"] | ||
pass_registry = os.environ["PSQL_REGISTRY_PASS"] | ||
except KeyError as e: | ||
raise RuntimeError("Addresses and passwords have not been configured") from e | ||
|
||
filename = os.path.join(os.environ["HOME"], ".pgpass") | ||
with open(filename, mode="wt") as file: | ||
file.write(f"{ip_apdb}:{PSQL_DB}:{PSQL_USER}:{pass_apdb}\n") | ||
file.write(f"{ip_registry}:{PSQL_DB}:{PSQL_USER}:{pass_registry}\n") | ||
# Only user may access the file | ||
os.chmod(filename, stat.S_IRUSR) |
This file contains hidden or 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 hidden or 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
Binary file not shown.
This file contains hidden or 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 hidden or 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,57 @@ | ||
# This file is part of prompt_prototype. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# 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/>. | ||
|
||
import json | ||
import unittest | ||
|
||
from activator.visit import Visit | ||
|
||
|
||
class VisitTest(unittest.TestCase): | ||
"""Test the Visit class's functionality. | ||
""" | ||
def setUp(self): | ||
super().setUp() | ||
|
||
self.testbed = Visit( | ||
instrument="NotACam", | ||
detector=42, | ||
group="2022032100001", | ||
snaps=2, | ||
filter="k2022", | ||
ra=134.5454, | ||
dec=-65.3261, | ||
rot=135.0, | ||
kind="IMAGINARY", | ||
) | ||
|
||
def test_hash(self): | ||
# Strictly speaking should test whether Visit fulfills the hash | ||
# contract, but it's not clear what kinds of differences the default | ||
# __hash__ might be insensitive to. So just test that the object | ||
# is hashable. | ||
value = hash(self.testbed) | ||
self.assertNotEqual(value, 0) | ||
|
||
def test_json(self): | ||
serialized = json.dumps(self.testbed.__dict__).encode("utf-8") | ||
deserialized = Visit(**json.loads(serialized)) | ||
self.assertEqual(deserialized, self.testbed) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.