Skip to content

Commit

Permalink
add run ranges and special ledcal
Browse files Browse the repository at this point in the history
  • Loading branch information
cfuselli committed Oct 23, 2024
1 parent 241f055 commit 43b1712
Showing 1 changed file with 39 additions and 14 deletions.
53 changes: 39 additions & 14 deletions amstrax/auto_processing_new/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,45 @@ def setup_amstrax(self):

self.db_utils = self.amstrax.db_utils

def get_run_doc_info(self):

# let's just print out the main info from the rundoc
# like mode, start, end, duration, user, comments, tags
# we'll need to format the date and time properly, and calculate the duration
# use datetime to convert the date to a readable format
log.info(f"Run document for run {self.run_id}:")
log.info(f" *** Mode: {self.run_doc.get('mode')}")
log.info(f" *** Start: {datetime.datetime.fromtimestamp(self.run_doc.get('start') / 1e9)}")
log.info(f" *** End: {datetime.datetime.fromtimestamp(self.run_doc.get('end') / 1e9)}")
log.info(f" *** Duration: {(self.run_doc.get('end') - self.run_doc.get('start'))/1e9:.2f} seconds")
log.info(f" *** User: {self.run_doc.get('user')}")
log.info(f" *** Comments: {self.run_doc.get('comments')}")
log.info(f" *** Tags: {self.run_doc.get('tags')}")
def get_run_doc_info(self):
""" This one is just to extract the run document details and log them. """

# Extract the run document details
start_date = self.run_doc.get('start')
end_date = self.run_doc.get('end')

# Check if start and end dates are in the expected format
if start_date and isinstance(start_date, dict) and '$date' in start_date:
start_timestamp = start_date['$date'] / 1e3 # Convert from milliseconds to seconds
start_datetime = datetime.datetime.fromtimestamp(start_timestamp)
else:
start_datetime = None

if end_date and isinstance(end_date, dict) and '$date' in end_date:
end_timestamp = end_date['$date'] / 1e3 # Convert from milliseconds to seconds
end_datetime = datetime.datetime.fromtimestamp(end_timestamp)
else:
end_datetime = None

# Calculate duration if both start and end times are available
if start_datetime and end_datetime:
duration = (end_timestamp - start_timestamp)
else:
duration = None

# Log the run document details
log.info(f"Run document for run {self.run_id}:")
log.info(f" *** Mode: {self.run_doc.get('mode')}")
if start_datetime:
log.info(f" *** Start: {start_datetime}")
if end_datetime:
log.info(f" *** End: {end_datetime}")
if duration is not None:
log.info(f" *** Duration: {duration:.2f} seconds")
log.info(f" *** User: {self.run_doc.get('user')}")
log.info(f" *** Comments: {self.run_doc.get('comments')}")
log.info(f" *** Tags: {self.run_doc.get('tags')}")


def infer_special_modes(self, st):

Expand Down

0 comments on commit 43b1712

Please sign in to comment.