-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor codebase, add timesformer support, improve tests (#24)
* refactor codebase, add timesformer support, improve tests * reformat * reformat * update workflow order * fix a test, add styling script * fix readme
- Loading branch information
Showing
14 changed files
with
263 additions
and
51 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
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import sys | ||
|
||
from tests.utils import shell, validate_and_exit | ||
|
||
if __name__ == "__main__": | ||
arg = sys.argv[1] | ||
|
||
if arg == "check": | ||
sts_flake = shell("flake8 . --config setup.cfg --select=E9,F63,F7,F82") | ||
sts_isort = shell("isort . --check --settings pyproject.toml") | ||
sts_black = shell("black . --check --config pyproject.toml") | ||
validate_and_exit(flake8=sts_flake, isort=sts_isort, black=sts_black) | ||
elif arg == "format": | ||
sts_isort = shell("isort . --settings pyproject.toml") | ||
sts_black = shell("black . --config pyproject.toml") | ||
validate_and_exit(isort=sts_isort, black=sts_black) |
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
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 @@ | ||
import os | ||
import shutil | ||
import sys | ||
|
||
|
||
def shell(command, exit_status=0): | ||
""" | ||
Run command through shell and return exit status if exit status of command run match with given exit status. | ||
Args: | ||
command: (str) Command string which runs through system shell. | ||
exit_status: (int) Expected exit status of given command run. | ||
Returns: actual_exit_status | ||
""" | ||
actual_exit_status = os.system(command) | ||
if actual_exit_status == exit_status: | ||
return 0 | ||
return actual_exit_status | ||
|
||
|
||
def validate_and_exit(expected_out_status=0, **kwargs): | ||
if all([arg == expected_out_status for arg in kwargs.values()]): | ||
# Expected status, OK | ||
sys.exit(0) | ||
else: | ||
# Failure | ||
print_console_centered("Summary Results") | ||
fail_count = 0 | ||
for component, exit_status in kwargs.items(): | ||
if exit_status != expected_out_status: | ||
print(f"{component} failed.") | ||
fail_count += 1 | ||
print_console_centered(f"{len(kwargs)-fail_count} success, {fail_count} failure") | ||
sys.exit(1) | ||
|
||
|
||
def print_console_centered(text: str, fill_char="="): | ||
w, _ = shutil.get_terminal_size((80, 20)) | ||
print(f" {text} ".center(w, fill_char)) |
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
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
Oops, something went wrong.