|
import datetime |
|
import re |
|
import subprocess |
|
from pathlib import Path |
|
|
|
import pandas as pd |
|
import typer |
|
|
|
SUBMISSION_FILES = ["README.md", "expert.py", "model.pt"] |
|
|
|
app = typer.Typer() |
|
|
|
def _update_submission_name(submission_name: str): |
|
replacement = "" |
|
with open("README.md", "r") as f: |
|
lines = f.readlines() |
|
|
|
for line in lines: |
|
if line.startswith("submission_name:"): |
|
changes = re.sub(r"submission_name:.+", f"submission_name: {submission_name}", line) |
|
replacement += changes |
|
else: |
|
replacement += line |
|
|
|
with open("README.md", "w") as f: |
|
f.write(replacement) |
|
|
|
|
|
@app.command() |
|
def validate(): |
|
|
|
for file in SUBMISSION_FILES: |
|
if not Path(file).is_file(): |
|
raise ValueError(f"File {file} not found! Please include {file} in your submission") |
|
|
|
typer.echo("All submission files validated! β¨ π β¨") |
|
typer.echo("Now you can make a submission π€") |
|
|
|
|
|
@app.command() |
|
def submit(submission_name: str = typer.Option(..., prompt="Please provide a name for your submission, e.g. HuBERT π")): |
|
subprocess.call("git pull origin main".split()) |
|
_update_submission_name(submission_name) |
|
subprocess.call(["git", "add", "model.pt", "README.md"]) |
|
subprocess.call(["git", "commit", "-m", f"Submission: {submission_name} "]) |
|
subprocess.call(["git", "push"]) |
|
|
|
today = datetime.date.today() |
|
|
|
idx = (today.weekday() + 1) % 7 |
|
sun = today + datetime.timedelta(7 - idx) |
|
typer.echo("Submission successful! π π₯³ π") |
|
typer.echo(f"Your submission will be evaulated on {sun:%A %d %B %Y} β³") |
|
|
|
|
|
if __name__ == "__main__": |
|
app() |
|
|