From a43c7f426bcd99413d0482198c70f79b9a5e02e2 Mon Sep 17 00:00:00 2001 From: g7gpr Date: Sun, 18 Jan 2026 03:01:28 +0000 Subject: [PATCH 1/6] Report upstream branch --- RMS/Formats/ObservationSummary.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/RMS/Formats/ObservationSummary.py b/RMS/Formats/ObservationSummary.py index 5444e02b0..91dec4652 100644 --- a/RMS/Formats/ObservationSummary.py +++ b/RMS/Formats/ObservationSummary.py @@ -1,6 +1,6 @@ # The MIT License -# Copyright (c) 2025 +# Copyright (c) 2026 # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -174,6 +174,19 @@ def getObservationDuration(config, start_time): return start_time_ephem, duration_ephem, end_time_ephem +def getUpstreamBranch(): + """Identify the active upstream branch + + Return: [str] active upstream branch + + """ + cmd = ["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"] + upstream_branch = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode().strip().splitlines()[0] + + return upstream_branch + + + def getTimeClient(): """Attempt to identify which time service client, if any is providing a service. @@ -1265,6 +1278,7 @@ def finalizeObservationSummary(config, night_data_dir, platepar=None): days_behind, remote_branch = daysBehind() addObsParam(obs_db_conn, "repository_lag_remote_days", days_behind) addObsParam(obs_db_conn, "remote_branch", os.path.basename(remote_branch)) + addObsParam(obs_db_conn, "upstream_branch", os.path.basename(getUpstreamBranch())) except: addObsParam(obs_db_conn, "repository_lag_remote_days", "Not determined") obs_db_conn.close() @@ -1292,7 +1306,7 @@ def finalizeObservationSummary(config, night_data_dir, platepar=None): print("Start time was {}".format(start_time)) print("Duration time was {:.2f} hours".format(duration/3600)) print("End time was {}".format(end_time)) - + print("Upstream branch is {}".format(getUpstreamBranch())) startObservationSummaryReport(config, 100, force_delete=False) From a12c23351d9157402edd84d258d3c4d7fd3da14c Mon Sep 17 00:00:00 2001 From: g7gpr Date: Sun, 18 Jan 2026 03:06:34 +0000 Subject: [PATCH 2/6] Report whole upstream branch --- RMS/Formats/ObservationSummary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RMS/Formats/ObservationSummary.py b/RMS/Formats/ObservationSummary.py index 91dec4652..4c57e0d7d 100644 --- a/RMS/Formats/ObservationSummary.py +++ b/RMS/Formats/ObservationSummary.py @@ -1278,7 +1278,7 @@ def finalizeObservationSummary(config, night_data_dir, platepar=None): days_behind, remote_branch = daysBehind() addObsParam(obs_db_conn, "repository_lag_remote_days", days_behind) addObsParam(obs_db_conn, "remote_branch", os.path.basename(remote_branch)) - addObsParam(obs_db_conn, "upstream_branch", os.path.basename(getUpstreamBranch())) + addObsParam(obs_db_conn, "upstream_branch", getUpstreamBranch()) except: addObsParam(obs_db_conn, "repository_lag_remote_days", "Not determined") obs_db_conn.close() From 673df64c03503e9f7f42f3dbba293f59b15956f0 Mon Sep 17 00:00:00 2001 From: g7gpr Date: Sun, 18 Jan 2026 03:08:51 +0000 Subject: [PATCH 3/6] Put upstream_branch in own try except --- RMS/Formats/ObservationSummary.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RMS/Formats/ObservationSummary.py b/RMS/Formats/ObservationSummary.py index 4c57e0d7d..897435ae8 100644 --- a/RMS/Formats/ObservationSummary.py +++ b/RMS/Formats/ObservationSummary.py @@ -1274,11 +1274,16 @@ def finalizeObservationSummary(config, night_data_dir, platepar=None): addObsParam(obs_db_conn, "protocol_in_use", config.protocol) addObsParam(obs_db_conn, "star_catalog_file", config.star_catalog_file) + try: + addObsParam(obs_db_conn, "upstream_branch", getUpstreamBranch()) + except: + addObsParam(obs_db_conn, "upstream_branch", "Not determined") + try: days_behind, remote_branch = daysBehind() addObsParam(obs_db_conn, "repository_lag_remote_days", days_behind) addObsParam(obs_db_conn, "remote_branch", os.path.basename(remote_branch)) - addObsParam(obs_db_conn, "upstream_branch", getUpstreamBranch()) + except: addObsParam(obs_db_conn, "repository_lag_remote_days", "Not determined") obs_db_conn.close() From 5ebc492d4d4597eecc26c41e1ea4621986c7c02a Mon Sep 17 00:00:00 2001 From: g7gpr Date: Sun, 18 Jan 2026 03:12:48 +0000 Subject: [PATCH 4/6] Correct output sequence for .txt --- RMS/Formats/ObservationSummary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RMS/Formats/ObservationSummary.py b/RMS/Formats/ObservationSummary.py index 897435ae8..50ea7c940 100644 --- a/RMS/Formats/ObservationSummary.py +++ b/RMS/Formats/ObservationSummary.py @@ -990,7 +990,7 @@ def retrieveObservationData(conn, config, night_directory=None, ordering=None): # the two items into one. ordering = ['stationID', - 'commit_date', 'commit_hash', 'remote_branch', 'repository_lag_remote_days', + 'commit_date', 'commit_hash', 'upstream_branch', 'remote_branch', 'repository_lag_remote_days', 'media_backend','star_catalog_file', 'hardware_version', 'captured_directories', From 8021166aa11ddf1cc6701ed8ffb390998bd3cc6b Mon Sep 17 00:00:00 2001 From: g7gpr Date: Sun, 18 Jan 2026 03:15:56 +0000 Subject: [PATCH 5/6] Use upstream branch for calculating days behind, unless the upstream branch no longer exists, in which case use the remote source of the current local commit --- RMS/Formats/ObservationSummary.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/RMS/Formats/ObservationSummary.py b/RMS/Formats/ObservationSummary.py index 50ea7c940..a1a1256c2 100644 --- a/RMS/Formats/ObservationSummary.py +++ b/RMS/Formats/ObservationSummary.py @@ -942,7 +942,10 @@ def daysBehind(): target_directory = target_directory_obj.name remote_urls = getRemoteUrls(os.getcwd()) commit_repo_directory = updateCommitHistoryDirectory(remote_urls, target_directory) - remote_branch_of_commit = getRemoteBranchNameForCommit(commit_repo_directory, latest_local_commit) + remote_branch_of_commit = getUpstreamBranch() + if remote_branch_of_commit is None: + remote_branch_of_commit = getRemoteBranchNameForCommit(commit_repo_directory, latest_local_commit) + if not remote_branch_of_commit is None: latest_remote_date = getDateOfCommit(commit_repo_directory, remote_branch_of_commit) days_behind = (latest_remote_date - latest_local_date).total_seconds()/(60 * 60 * 24) @@ -1277,7 +1280,7 @@ def finalizeObservationSummary(config, night_data_dir, platepar=None): try: addObsParam(obs_db_conn, "upstream_branch", getUpstreamBranch()) except: - addObsParam(obs_db_conn, "upstream_branch", "Not determined") + addObsParam(obs_db_conn, "upstream_branch", None) try: days_behind, remote_branch = daysBehind() From 584f95f40ffea4c08b028ff9429b1662cb76acc9 Mon Sep 17 00:00:00 2001 From: g7gpr Date: Sun, 18 Jan 2026 03:28:28 +0000 Subject: [PATCH 6/6] Use upstream branch for calculating days behind, unless the upstream branch no longer exists, in which case use the remote source of the current local commit --- RMS/Formats/ObservationSummary.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RMS/Formats/ObservationSummary.py b/RMS/Formats/ObservationSummary.py index a1a1256c2..ca1b049ed 100644 --- a/RMS/Formats/ObservationSummary.py +++ b/RMS/Formats/ObservationSummary.py @@ -1192,7 +1192,8 @@ def startObservationSummaryReport(config, duration, force_delete=False): captured_directories = captureDirectories(os.path.join(config.data_dir, config.captured_dir), config.stationID) addObsParam(conn, "captured_directories", captured_directories) try: - addObsParam(conn, "camera_information", gatherCameraInformation(config)) + pass + # addObsParam(conn, "camera_information", gatherCameraInformation(config)) except: addObsParam(conn, "camera_information", "Unavailable")