-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into smartfin_2024_2
- Loading branch information
Showing
7 changed files
with
120 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -19,7 +21,7 @@ | |
} | ||
}, | ||
'schedule': { | ||
int: [str] | ||
str: [str] | ||
} | ||
} | ||
) | ||
|
@@ -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]): | ||
|
@@ -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 = [ | ||
|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters