Skip to content

Commit

Permalink
Fix prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ZainRizvi committed May 5, 2023
1 parent 9b7d3d9 commit 5d0e8e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/scripts/file_io_utils.py
Expand Up @@ -84,4 +84,7 @@ def download_s3_objects_with_prefix(bucket, prefix, download_folder):
downloads.append(download_path)
print("done")

if len(downloads) == 0:
print(f"There were no files matching the prefix `{prefix}` in bucket `{bucket.name}`")

return downloads
15 changes: 3 additions & 12 deletions .github/scripts/pytest_caching_utils.py
Expand Up @@ -22,10 +22,11 @@

# create a custom string type to be used as pr identifiers to know we've gotten the right one
class PRIdentifier(str):
def __init__(self, value):
def __new__(cls, value):
# Since the pr identifier can be based on include user defined text (like a branch name)
# we hash it to get a clean input and dodge corner cases
self.value = hashlib.md5(value.encode()).hexdigest()
md5 = hashlib.md5(value.encode('utf-8')).hexdigest()
return super().__new__(cls, md5)


def get_s3_key_prefix(
Expand Down Expand Up @@ -139,16 +140,6 @@ def download_pytest_cache(
# shutil.rmtree(zip_download_dir) suppress deletes while testing
pass

def unzip_cache_folder(zip_file_path, dest_dir):
# the file name of the zip is the shard id
shard_id = os.path.splitext(os.path.basename(zip_file_path))[0]
cache_dir_for_shard = os.path.join(
dest_dir,
get_s3_key_prefix(pr_identifier, workflow, job, shard_id),
PYTEST_CACHE_DIR_NAME,
)

unzip_folder(downloaded_zip, cache_dir_for_shard)

def copy_file(source_file, dest_file):
ensure_dir_exists(os.path.dirname(dest_file))
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/_linux-test.yml
Expand Up @@ -115,11 +115,11 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
test-matrix: ${{ inputs.test-matrix }}

# - name: Download pytest cache
# uses: ./.github/actions/pytest-cache-download
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# cache_dir: ${GITHUB_WORKSPACE}/.pytest_cache
- name: Download pytest cache
uses: ./.github/actions/pytest-cache-download
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
cache_dir: .pytest_cache

- name: Set Test step time
id: test-timeout
Expand Down

0 comments on commit 5d0e8e2

Please sign in to comment.