Skip to content

Commit

Permalink
Merge branch 'main' into smartfin_2024_2
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Jan 3, 2024
2 parents 93ec9dd + 157aeb5 commit 9f7a406
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 45 deletions.
4 changes: 3 additions & 1 deletion active_all_call.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
\item Radio Telemetry Tracker
\item Mangrove Monitoring
\item FishSense
\item Baboons on the Move
\item Acoustic Species ID
\item Baboons on the Move
5 changes: 2 additions & 3 deletions active_order.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
\item Fishsense
\item Radio Telemetry Tracker
\item Smartfin
\item Smartfin
\item Hardware Development Group
8 changes: 3 additions & 5 deletions active_sections.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
\section{Fishsense}
\include{project_fs}
\section{Radio Telemetry Tracker}
\include{project_rtt}
\section{Smartfin}
\include{project_sf}
\include{project_sf}
\section{Hardware Development Group}
\include{project_hw}
18 changes: 9 additions & 9 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ projects:
- ntlhui
schedule:
# Keyed by ISO Week Number of presentation
2: [smartfin, hardware]
3: [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 2
4: [fishsense, radio_telemetry_tracker, smartfin] # WI24 3
5: [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 4
6: [fishsense, radio_telemetry_tracker, smartfin] # WI24 5
7: [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 6
8: [fishsense, radio_telemetry_tracker, smartfin] # WI24 7
9: [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 8
10: [fishsense, radio_telemetry_tracker, smartfin] # WI24 9
'2024-01-10': [smartfin, hardware]
'2024-01-17': [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 2
'2024-01-24': [fishsense, radio_telemetry_tracker, smartfin] # WI24 3
'2024-01-31': [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 4
'2024-02-07': [fishsense, radio_telemetry_tracker, smartfin] # WI24 5
'2024-02-14': [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 6
'2024-02-21': [fishsense, radio_telemetry_tracker, smartfin] # WI24 7
'2024-02-28': [mangrove_monitoring, acoustic_species_id, baboons_on_the_move] # WI24 8
'2024-03-06': [fishsense, radio_telemetry_tracker, smartfin] # WI24 9
87 changes: 61 additions & 26 deletions configure_presentation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
''' Presentation Configuration
'''
import datetime as dt
import os
import shlex
import subprocess
from typing import Dict, List, Set, Tuple
from typing import Dict, List, Sequence, Set

import pytz
import schema
Expand All @@ -19,7 +21,7 @@
}
},
'schedule': {
int: [str]
str: [str]
}
}
)
Expand All @@ -30,29 +32,39 @@ def main():
"""
timezone = pytz.timezone('America/Los_Angeles')
exec_timestamp = dt.datetime.now(timezone)
calendar_tuple = exec_timestamp.isocalendar()
next_weeknum = calendar_tuple[1] + 1

# Read schedule from schedule.yml
with open('config.yml', 'r', encoding='utf-8') as handle:
data = yaml.safe_load(handle)
config = config_schema.validate(data)

# allow assert - we want the action to fail if the current week is not supported
schedule = config['schedule']
assert next_weeknum in schedule

current_projects: List[str] = schedule[next_weeknum]
raw_schedule: Dict[str, List[str]] = config['schedule']
full_schedule = {dt.date.fromisoformat(
key): value for key, value in raw_schedule.items()}
future_schedule = {date: sequence
for date, sequence in full_schedule.items()
if date > exec_timestamp.date()}
assert len(future_schedule) > 0
next_date = min(future_schedule.keys())

current_projects: List[str] = future_schedule[next_date]
print(current_projects)
projects: Dict = config['projects']
all_call_projects: Set[str] = set(
projects.keys()).difference(current_projects)
print(all_call_projects)
_exec_cmd(
['git', 'config', 'user.email', '[email protected]']
)
_exec_cmd(
['git', 'config', 'user.name', 'E4E GitHub Actions']
)

__update_latex(current_projects, projects, all_call_projects)

# Create the appropriate branches
__create_branches(current_projects, projects, calendar_tuple)
__create_branches(current_projects, projects, next_date)


def __update_latex(current_projects: List[str], projects: Dict, all_call_projects: Set[str]):
Expand All @@ -69,38 +81,50 @@ def __update_latex(current_projects: List[str], projects: Dict, all_call_project
handle.write(f'\\section{{{projects[project]["name"]}}}\n')
handle.write(f'\\include{{{projects[project]["latex"]}}}\n')

_exec_cmd(
[
'git', 'add',
'active_all_call.tex',
'active_order.tex',
'active_sections.tex'
]
)
_exec_cmd([
'git', 'commit',
'-m', f'feat!: Configures presentation for {", ".join(current_projects)}'
])
_exec_cmd([
'git', 'push'
])


def __create_branches(current_projects: List[str],
projects: Dict,
calendar_tuple: Tuple):
current_year = calendar_tuple[0]
next_weeknum = calendar_tuple[1] + 1
subprocess.check_call(
['git', 'config', 'user.email', '[email protected]']
)
subprocess.check_call(
['git', 'config', 'user.name', 'E4E GitHub Actions']
)
presentation_date: dt.date):

for project in current_projects:
project_params = projects[project]
branch_name = f'{project_params["branch"]}_{current_year}_{next_weeknum}'
subprocess.check_call(
branch_name = f'{project_params["branch"]}_{presentation_date.isoformat()}'
_exec_cmd(
['git', 'checkout', 'main']
)
_exec_cmd(
['git', 'checkout', '-b', branch_name]
)
# Reset the slides
with open('base_project.tex', 'r', encoding='utf-8') as reference_handle, \
open(project_params['latex'] + '.tex', 'w', encoding='utf-8') as target_handle:
target_handle.write(
f'% Slides for {current_year} Week {next_weeknum}\n')
f'% Slides for {presentation_date.isoformat()}\n')
for line in reference_handle:
target_handle.write(line)
subprocess.check_call(
_exec_cmd(
['git', 'add', project_params['latex'] + '.tex']
)
subprocess.check_call(
_exec_cmd(
['git', 'commit', '-m', 'fix: Resetting slides']
)
subprocess.check_call(
_exec_cmd(
['git', 'push', '--set-upstream', 'origin', branch_name]
)
command = [
Expand All @@ -109,14 +133,25 @@ def __create_branches(current_projects: List[str],
'-t', project_params['name'],
'-d',
'-H', branch_name,
'-b', f'Weekly presentation slides for {project_params["name"]}'
'-b', (f'Weekly presentation slides for {project_params["name"]} for '
f'{presentation_date.isoformat()}')
]
for assignee in project_params['assignees']:
command.extend(('-a', assignee))
subprocess.check_call(
_exec_cmd(
command
)


def _exec_cmd(cmd: Sequence[str]):
# only exec if GH_TOKEN is defined, i.e. in GitHub Actions
if 'GH_TOKEN' in os.environ:
subprocess.check_call(
args=cmd
)
else:
print(shlex.join(cmd))


if __name__ == '__main__':
main()
41 changes: 41 additions & 0 deletions project_hw.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
% Slides for 2024-01-10
% To create a slide, use the following:
% \begin{frame}{TITLE}
% BODY
% \end{frame}

% To create a slide with a bullet list, use the following:
% \begin{frame}{TITLE}
% \begin{itemize}
% \item ITEM 1
% \item ITEM 2
% \end{itemize}
% \end{frame}

% To create a slide with numbered list, use the following:
% \begin{frame}{TITLE}
% \begin{enumerate}
% \item ITEM 1
% \item ITEM 2
% \end{enumerate}
% \end{frame}

% To create a slide with a graphic:
% 1. Add the graphic to this folder (named picture.png)
% 2. Use the following:
% \begin{frame}{TITLE}
% \centering
% \includegraphics[height=0.7\textheight,width=0.7\textwidth,keepaspectratio]{picture.png}
% \end{frame}

% To create a slide with two columns, use the following:
% \begin{frame}{TITLE}
% \begin{columns}
% \begin{column}{0.5\textwidth}
% COLUMN 1 BODY
% \end{column}
% \begin{column}{0.5\textwidth}
% COLUMN 2 BODY
% \end{column}
% \end{columns}
% \end{frame}
2 changes: 1 addition & 1 deletion project_sf.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Slides for 2024 Week 2
% Slides for 2024-01-10
% To create a slide, use the following:
% \begin{frame}{TITLE}
% BODY
Expand Down

0 comments on commit 9f7a406

Please sign in to comment.