Skip to content

Commit

Permalink
Merge branch 'dev' into add-docs-v2
Browse files Browse the repository at this point in the history
Pulling changes from new release
  • Loading branch information
nevoodoo committed Jan 17, 2024
2 parents 311e044 + fcf07f2 commit e2b5d6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ async def exception_handler(request: Request, e: Exception):
cors_middleware = middlewares[0]

request_origin = request.headers.get('origin', '')
if cors_middleware and '*' in cors_middleware.options['allow_origins']:
if cors_middleware and '*' in cors_middleware.options['allow_origins']: # type: ignore
response.headers['Access-Control-Allow-Origin'] = '*'
elif (
cors_middleware
and request_origin in cors_middleware.options['allow_origins']
and request_origin in cors_middleware.options['allow_origins'] # type: ignore
):
response.headers['Access-Control-Allow-Origin'] = request_origin

Expand Down
21 changes: 11 additions & 10 deletions scripts/create_md5s.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@ def create_md5s_for_files_in_directory(skip_filetypes: tuple[str, str], force_re
if not gs_dir.startswith('gs://'):
raise ValueError(f'Expected GS directory, got: {gs_dir}')

billing_project = get_config()['hail']['billing_project']
billing_project = get_config()['workflow']['gcp_billing_project']
driver_image = get_config()['workflow']['driver_image']

bucket_name, *components = gs_dir[5:].split('/')

client = storage.Client()
blobs = client.list_blobs(bucket_name, prefix='/'.join(components))
bucket = client.bucket(bucket_name, user_project=billing_project)
blobs = bucket.list_blobs(prefix='/'.join(components))
files: set[str] = {f'gs://{bucket_name}/{blob.name}' for blob in blobs}
for obj in files:
if obj.endswith('.md5') or obj.endswith(skip_filetypes):
for filepath in files:
if filepath.endswith('.md5') or filepath.endswith(skip_filetypes):
continue
if f'{obj}.md5' in files and not force_recreate:
print(f'{obj}.md5 already exists, skipping')
if f'{filepath}.md5' in files and not force_recreate:
print(f'{filepath}.md5 already exists, skipping')
continue

print('Creating md5 for', obj)
job = b.new_job(f'Create {os.path.basename(obj)}.md5')
create_md5(job, obj, billing_project, driver_image)
print('Creating md5 for', filepath)
job = b.new_job(f'Create {os.path.basename(filepath)}.md5')
create_md5(job, filepath, billing_project, driver_image)

b.run(wait=False)

Expand All @@ -46,7 +47,7 @@ def create_md5(job, file, billing_project, driver_image):
f"""\
set -euxo pipefail
gcloud -q auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
gsutil cat {file} | md5sum | cut -d " " -f1 > /tmp/uploaded.md5
gsutil -u {billing_project} cat {file} | md5sum | cut -d " " -f1 > /tmp/uploaded.md5
gsutil -u {billing_project} cp /tmp/uploaded.md5 {md5}
"""
)
Expand Down

0 comments on commit e2b5d6f

Please sign in to comment.