Skip to content

Commit

Permalink
Merge pull request #150 from sennetconsortium/maxsibilla/werkzeug-fix
Browse files Browse the repository at this point in the history
Maxsibilla/werkzeug fix
  • Loading branch information
maxsibilla authored Oct 2, 2023
2 parents e24e95e + f62730f commit 6c3f875
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Flask==2.1.3
globus_sdk==2.0.1
hubmap-sdk==1.0.4
Werkzeug==2.1.0

# The commons package requires requests>=2.22.0
requests==2.25.1
Expand Down
27 changes: 16 additions & 11 deletions src/routes/entity_CRUD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import re
import datetime
import time
from typing import List
import urllib.request
import yaml
Expand Down Expand Up @@ -988,39 +989,43 @@ def submit_upload(upload_uuid):
#AirFlow interface
@entity_CRUD_blueprint.route('/uploads/<upload_uuid>/validate', methods=['PUT'])
def validate_upload(upload_uuid):
start_time = time.time()
if not request.is_json:
return Response("json request required", 400)

upload_changes = request.json

#get auth info to use in other calls
#add the app specific header info
# get auth info to use in other calls
# add the app specific header info
http_headers = {
'Authorization': request.headers["AUTHORIZATION"],
'Content-Type': 'application/json',
'X-SenNet-Application':'ingest-api'
'X-SenNet-Application': 'ingest-api'
}

#update the Upload with any changes from the request
#and change the status to "Processing", the validate
#pipeline will update the status when finished
# update the Upload with any changes from the request
# and change the status to "Processing", the validate
# pipeline will update the status when finished

#run the pipeline validation
# run the pipeline validation
upload_changes['status'] = 'Processing'
update_url = commons_file_helper.ensureTrailingSlashURL(current_app.config['ENTITY_WEBSERVICE_URL']) + 'entities/' + upload_uuid

# Disable ssl certificate verification
resp = requests.put(update_url, headers=http_headers, json=upload_changes, verify = False)
resp = requests.put(update_url, headers=http_headers, json=upload_changes, verify=False)
if resp.status_code >= 300:
return Response(resp.text, resp.status_code)
logger.debug("--- %s seconds to update Entity API ---" % (time.time() - start_time))

#disable validations stuff for now...
# disable validations stuff for now...
##call the AirFlow validation workflow
validate_url = commons_file_helper.ensureTrailingSlashURL(current_app.config['INGEST_PIPELINE_URL']) + 'uploads/' + upload_uuid + "/validate"
validate_url = commons_file_helper.ensureTrailingSlashURL(
current_app.config['INGEST_PIPELINE_URL']) + 'uploads/' + upload_uuid + "/validate"
## Disable ssl certificate verification
resp2 = requests.put(validate_url, headers=http_headers, json=upload_changes, verify = False)
resp2 = requests.put(validate_url, headers=http_headers, json=upload_changes, verify=False)
if resp2.status_code >= 300:
return Response(resp2.text, resp2.status_code)
logger.debug("--- %s seconds to send validate request to Airflow ---" % (time.time() - start_time))

return Response(resp.text, resp.status_code)

Expand Down

0 comments on commit 6c3f875

Please sign in to comment.