Skip to content

DM-44387: Add several convenience methods.#106

Merged
ktlim merged 4 commits intomainfrom
tickets/DM-44387
May 23, 2024
Merged

DM-44387: Add several convenience methods.#106
ktlim merged 4 commits intomainfrom
tickets/DM-44387

Conversation

@ktlim
Copy link
Copy Markdown
Collaborator

@ktlim ktlim commented May 20, 2024

compute_exposure_id and compute_ccdexposure_id generate unique numeric ids locally without a server round-trip, since summit_utils already depends on afw.

compute_fixed_metadata_namespace is useful for generating query strings.

insert_multiple allows many rows to be inserted at once (e.g. for many detectors in a focal plane).

compute_exposure_id and compute_ccdexposure_id generate unique numeric ids
locally without a server round-trip, since summit_utils already depends on afw.

compute_fixed_metadata_namespace is useful for generating query strings.

insert_multiple allows many rows to be inserted at once (e.g. for many
detectors in a focal plane).
@ktlim ktlim force-pushed the tickets/DM-44387 branch from c02400e to 2bc3b75 Compare May 20, 2024 07:18
@ktlim ktlim requested a review from mfisherlevine May 21, 2024 14:05
Copy link
Copy Markdown
Contributor

@mfisherlevine mfisherlevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, minor comments about potentially moving the static methods. Just make sure to run the pre-commit hooks, guess you forced this to push, right?

response.raise_for_status()
return response

@staticmethod
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these static methods go to being free-floating functions? I think they'd be useful in other places as well as here, and they're fully generic. Given that, would you be up for putting them in utils.py in here, or some other file. so that they can be imported more naturally than putting them in the consdbClient? (and camelCasing while you're at it, given that?! 😬)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of instrument.lower() is somewhat database-specific (most other places use the official capitalized name or a Python class name with its own distinct capitalization), but yes these could be moved.

def compute_exposure_id(instrument: str, controller: str, day_obs: int, seq_num) -> int:
instrument = instrument.lower()
if instrument == "latiss":
from lsst.obs.lsst.translators import LatissTranslator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these imports particularly costly or something? I think everything in summit_utils has generally already imported the world, so if that's why these imports aren't at the top then I don't think it really matters. Was that the reason for putting them here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only things in ConsDbClient that required anything stack-specific. Moving them out would mean that there's no need to hide them.

@ktlim ktlim force-pushed the tickets/DM-44387 branch 3 times, most recently from 6e626bc to b0539d6 Compare May 23, 2024 18:02
@ktlim ktlim force-pushed the tickets/DM-44387 branch from b0539d6 to de16dea Compare May 23, 2024 18:04
@ktlim ktlim merged commit eb62f08 into main May 23, 2024
@ktlim ktlim deleted the tickets/DM-44387 branch May 23, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants