Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 24, 2023
1 parent 0921913 commit ab33cd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
6 changes: 2 additions & 4 deletions deployer/cluster.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import os
import sys
import subprocess
import sys
import tempfile
from contextlib import contextmanager
from pathlib import Path
Expand Down Expand Up @@ -153,7 +153,7 @@ def auth_aws(self):
f"--region={region}",
],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE
stdout=subprocess.PIPE,
)

if proc.returncode != 0:
Expand All @@ -162,7 +162,6 @@ def auth_aws(self):
print(proc.stderr.decode(), file=sys.stderr)
proc.check_returncode()


yield

def auth_azure(self):
Expand Down Expand Up @@ -259,7 +258,6 @@ def auth_gcp(self):
print(proc.stdout.decode())
print(proc.stderr.decode(), file=sys.stderr)
proc.check_returncode()


proc = subprocess.run(
[
Expand Down
43 changes: 16 additions & 27 deletions reports/run.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,38 @@
"""
Execute the reports in this directory with papermill & output them to a github repo
"""
import papermill as pm
import argparse
import os
from datetime import datetime
import pathlib
from contextlib import contextmanager
import argparse
import subprocess
from contextlib import contextmanager
from datetime import datetime
from tempfile import TemporaryDirectory

import papermill as pm

HERE = pathlib.Path(__file__).parent


@contextmanager
def auto_commit_git_repo(clone_url, message):
with TemporaryDirectory() as d:
subprocess.check_call([
'git', 'clone',
clone_url,
'--depth', '1',
d
])
subprocess.check_call(["git", "clone", clone_url, "--depth", "1", d])
try:
yield d
finally:
subprocess.check_call([
'git', 'add', '.'
], cwd=d)
subprocess.check_call([
'git', 'commit', '-m', message
], cwd=d)
subprocess.check_call([
'git', 'push'
], cwd=d)

subprocess.check_call(["git", "add", "."], cwd=d)
subprocess.check_call(["git", "commit", "-m", message], cwd=d)
subprocess.check_call(["git", "push"], cwd=d)


reports = HERE.glob('*.ipynb')
reports = HERE.glob("*.ipynb")

with auto_commit_git_repo('[email protected]:yuvipanda/2i2c-reports.git', 'Test commits') as d:
with auto_commit_git_repo(
"[email protected]:yuvipanda/2i2c-reports.git", "Test commits"
) as d:
output_base = pathlib.Path(d)
for report in reports:
output_file = output_base / report.stem / datetime.now().isoformat()
output_file = output_base / report.stem / datetime.now().isoformat()
os.makedirs(output_file.parent, exist_ok=True)
pm.execute_notebook(
report,
str(output_file) + ".ipynb"
)
pm.execute_notebook(report, str(output_file) + ".ipynb")

0 comments on commit ab33cd7

Please sign in to comment.