Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Use cached datasets in GitHub Actions #107

Merged
merged 9 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,15 @@ jobs:
uses: actions/cache@v2
with:
path: data # This path is specific to Ubuntu
# Look to see if there is a cache hit for the corresponding requirements file
key: flash-datasets
key: flash-datasets-${{ hashFiles('tests/examples/test_examples.py') }}
restore-keys: flash-datasets-

- name: Tests
run: |
# tox --sitepackages
coverage run --source flash -m pytest flash tests -v --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
coverage xml

#- name: Run examples
# run: |
# # tox --sitepackages
# python -m pip install -e .
# # python flash_examples/torchvision_classifier.py

- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
Expand Down
16 changes: 8 additions & 8 deletions tests/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
root = Path(__file__).parent.parent.parent


def call_script(filepath: str,
args: Optional[List[str]] = None,
timeout: Optional[int] = 60 * 5) -> Tuple[int, str, str]:
def call_script(
filepath: str,
args: Optional[List[str]] = None,
timeout: Optional[int] = 60 * 5,
) -> Tuple[int, str, str]:
if args is None:
args = []
args = [str(a) for a in args]
Expand All @@ -42,9 +44,9 @@ def call_script(filepath: str,

def run_test(filepath):
code, stdout, stderr = call_script(filepath)
assert not code
print(f"{filepath} STDOUT: {stdout}")
print(f"{filepath} STDERR: {stderr}")
assert not code


@pytest.mark.parametrize(
Expand All @@ -58,10 +60,8 @@ def run_test(filepath):
]
)
def test_finetune_example(tmpdir, step, file):
with tmpdir.as_cwd():
Copy link
Contributor Author

@akihironitta akihironitta Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path tmpdir.as_cwd() is all different in each test parametrized above, which led to downloading the same dataset to different places.

run_test(str(root / "flash_examples" / step / file))
run_test(str(root / "flash_examples" / step / file))


def test_generic_example(tmpdir):
with tmpdir.as_cwd():
run_test(str(root / "flash_examples" / "generic_task.py"))
run_test(str(root / "flash_examples" / "generic_task.py"))