Skip to content
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

Only search run info in the DB for actual data runs #246

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion osa/nightsummary/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
caco_client.server_info()
tcu_client.server_info()
except ConnectionFailure:
log.info("TCU or CaCo database not available. No source info will be added.")
log.warning("TCU or CaCo database not available. No source info will be added.")
return False
else:
log.debug("TCU and CaCo database are available. Source info will be added.")

Check warning on line 33 in osa/nightsummary/database.py

View check run for this annotation

Codecov / codecov/patch

osa/nightsummary/database.py#L33

Added line #L33 was not covered by tests
return True


Expand Down
42 changes: 25 additions & 17 deletions osa/nightsummary/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,31 @@
dtype=["int32", str, "float64", "float64"],
)
for run in run_list:
run.source_name = database.query(
obs_id=run.run, property_name="DriveControl_SourceName"
)
run.source_ra = database.query(obs_id=run.run, property_name="DriveControl_RA_Target")
run.source_dec = database.query(obs_id=run.run, property_name="DriveControl_Dec_Target")
# Store this source information (run_id, source_name, source_ra, source_dec)
# into an astropy Table and save to disk. In this way, the information can be
# dumped anytime later more easily than accessing the TCU database itself.
if run.source_name is not None:
line = [
run.run,
run.source_name,
run.source_ra,
run.source_dec,
]
log.debug(f"Adding line with source info to RunCatalog: {line}")
run_table.add_row(line)
# Make sure we are looking at actual data runs. Avoid test runs.
if run.run > 0 and run.type == "DATA":
log.debug(f"Looking info in TCU DB for run {run.run}")
run.source_name = database.query(

Check warning on line 176 in osa/nightsummary/extract.py

View check run for this annotation

Codecov / codecov/patch

osa/nightsummary/extract.py#L174-L176

Added lines #L174 - L176 were not covered by tests
obs_id=run.run, property_name="DriveControl_SourceName"
)
run.source_ra = database.query(

Check warning on line 179 in osa/nightsummary/extract.py

View check run for this annotation

Codecov / codecov/patch

osa/nightsummary/extract.py#L179

Added line #L179 was not covered by tests
obs_id=run.run, property_name="DriveControl_RA_Target"
)
run.source_dec = database.query(

Check warning on line 182 in osa/nightsummary/extract.py

View check run for this annotation

Codecov / codecov/patch

osa/nightsummary/extract.py#L182

Added line #L182 was not covered by tests
obs_id=run.run, property_name="DriveControl_Dec_Target"
)
# Store this source information (run_id, source_name, source_ra, source_dec)
# into an astropy Table and save to disk in RunCatalog files. In this way, the
# information can be dumped anytime later more easily than accessing the
# TCU database.
if run.source_name is not None:
line = [

Check warning on line 190 in osa/nightsummary/extract.py

View check run for this annotation

Codecov / codecov/patch

osa/nightsummary/extract.py#L189-L190

Added lines #L189 - L190 were not covered by tests
run.run,
run.source_name,
run.source_ra,
run.source_dec,
]
log.debug(f"Adding line with source info to RunCatalog: {line}")
run_table.add_row(line)

Check warning on line 197 in osa/nightsummary/extract.py

View check run for this annotation

Codecov / codecov/patch

osa/nightsummary/extract.py#L196-L197

Added lines #L196 - L197 were not covered by tests

# Save table to disk
run_table.write(source_catalog_file, overwrite=True, delimiter=",")
Expand Down