Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MIME types to include application/gzip; Validate prints to stderr instead of stdout #109

Merged
merged 9 commits into from
Nov 23, 2024
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
62 changes: 21 additions & 41 deletions .github/workflows/Docker-build-release.yaml
Original file line number Diff line number Diff line change
@@ -1,53 +1,33 @@
---
name: Docker-build-release
name: Update image in GHCR

run-name: >
${{
github.event_name == 'delete' && format(
'Delete `{0}{1}`',
github.event.ref_type == 'branch' && 'branch-' || '',
github.event.ref
)
|| github.ref == 'refs/heads/main' && 'Update `dev`'
|| format(
'Update `{0}{1}`',
!startsWith(github.ref, 'refs/tags') && 'branch-' || '',
github.ref_name
)
}} docker tag

on:
push:
branches: ['main']
branches-ignore: ['gh-pages']
tags: ['v*']
release:
types: [published]
delete:

jobs:
build-and-push-image:
push-or-delete-image:
runs-on: ubuntu-latest
name: A job to build and push a docker image
name: Update GitHub Container Registry
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Read YAML
id: yaml-data
uses: jbutcher5/[email protected]
with:
file: metadata.yaml
key-path: '["image_name"]'

- name: Create tags
id: meta
uses: docker/metadata-action@v3
with:
flavor: |
latest=false
images: ghcr.io/uclahs-cds/${{ steps.yaml-data.outputs.data }}
tags: |
type=raw,enable=${{github.event_name == 'push'}},value=dev,event=branch
type=match,pattern=v(.*),group=1
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io/uclahs-cds
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
file: ./docker/Dockerfile
- uses: uclahs-cds/tool-Docker-action@v2
yashpatel6 marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
6 changes: 3 additions & 3 deletions pipeval/validate/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def _validate_file(

def _print_error(path:Path, err:BaseException):
''' Prints error message '''
print(f'PID:{os.getpid()} - Error: `{str(path)}` {str(err)}')
print(f'PID:{os.getpid()} - Error: `{str(path)}` {str(err)}', file=sys.stderr)

def _print_success(path:Path, file_type:str):
''' Prints success message '''
print(f'PID:{os.getpid()} - Input: `{path}` is valid {file_type}')
print(f'PID:{os.getpid()} - Input: `{path}` is valid {file_type}', file=sys.stderr)

def _detect_file_type_and_extension(path:Path):
''' File type and extension detection '''
Expand Down Expand Up @@ -98,7 +98,7 @@ def _validation_worker(path: Path, args:Union[ValidateArgs,Dict[str, Union[str,l
file_type, file_extension = _detect_file_type_and_extension(path)
_validate_file(path, file_type, file_extension, args)
except FileNotFoundError as file_not_found_err:
print(f"Warning: {str(path)} {str(file_not_found_err)}")
print(f"Warning: {str(path)} {str(file_not_found_err)}", file=sys.stderr)
except (TypeError, ValueError, IOError, OSError) as err:
_print_error(path, err)
return False
Expand Down
1 change: 1 addition & 0 deletions pipeval/validate/validators/fastq.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _get_file_handler(self):
'''Detect file format and return approriate handler to read file'''
_handler_map = {
'application/x-gzip': gzip.open,
'application/gzip': gzip.open,
'application/x-bzip2': bz2.open,
'text/plain': open
}
Expand Down
3 changes: 3 additions & 0 deletions test/unit/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def test__check_compressed__raises_warning_for_uncompressed_path(mock_path, mock
'compression_mime',
[
('application/x-gzip'),
('application/gzip'),
('application/x-bzip2')
]
)
Expand Down Expand Up @@ -491,6 +492,7 @@ def test__validate_record__passes_valid_read():
'test_file_type, test_handler',
[
('application/x-gzip', gzip.open),
('application/gzip', gzip.open),
('application/x-bzip2', bz2.open),
('text/plain', open)
]
Expand Down Expand Up @@ -580,6 +582,7 @@ def test__validate_fastq__passes_valid_fastq(
'test_file_type, test_handler',
[
('application/x-gzip', gzip.open),
('application/gzip', gzip.open),
('application/x-bzip2', bz2.open),
('any/other', None)
]
Expand Down
Loading