Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1894f43
Updated requirements.txt. Fixed pylint issues. Updated test gen script
Nov 2, 2018
b85f23b
Added 2 new tables. Renamed tables to support ordered deploy
Nov 3, 2018
17a2247
Added support for user creating and auditing in DB, DAL, and deployment.
Nov 4, 2018
ec75f81
Removed comment
Nov 4, 2018
35740c9
Change
andrebriggs Nov 4, 2018
e09739a
merging from upstream
andrebriggs Nov 5, 2018
dd0723e
Adding support to check if db already exists.
andrebriggs Nov 5, 2018
f8ead27
Added comment
andrebriggs Nov 6, 2018
3e339ce
Fixed issue in db resoruces install file. Updated table schema
andrebriggs Nov 7, 2018
4dcec72
Updated deployment to be more idempotent. Updated table schemas
andrebriggs Nov 8, 2018
475abbe
Added a new version of the data access layer. Added simple unit tests.
andrebriggs Nov 8, 2018
df69e48
Merging
andrebriggs Nov 8, 2018
1df6d66
Added comments
andrebriggs Nov 8, 2018
c3949cb
Fixed issue
andrebriggs Nov 8, 2018
b9b076a
Changed query formatting in some areas
andrebriggs Nov 8, 2018
c55ccec
Removing unused files
andrebriggs Nov 8, 2018
75b6e80
Removed __init__.py that was causing pytest issues. Updated yaml.
andrebriggs Nov 8, 2018
11468fb
Merge remote-tracking branch 'upstream/master'
andrebriggs Nov 8, 2018
d0c7483
Added packages
andrebriggs Nov 8, 2018
2d4b857
Fixed format issue
andrebriggs Nov 8, 2018
bc270b2
Fixing more linting issues
andrebriggs Nov 8, 2018
6cca44a
Removing 3.5 from matrix
andrebriggs Nov 9, 2018
7f794fb
Changes to enforce Tagging_User as a key in the CLI config
andrebriggs Nov 9, 2018
ab9ed70
Updated requirements.txt. Fixed pylint issues. Updated test gen script
Nov 2, 2018
b96b872
Added 2 new tables. Renamed tables to support ordered deploy
Nov 3, 2018
55e1d1f
Added support for user creating and auditing in DB, DAL, and deployment.
Nov 4, 2018
f156e55
Adding support to check if db already exists.
andrebriggs Nov 5, 2018
71a52ef
Added comment
andrebriggs Nov 6, 2018
c099e0c
Fixed issue in db resoruces install file. Updated table schema
andrebriggs Nov 7, 2018
678eabc
Updated deployment to be more idempotent. Updated table schemas
andrebriggs Nov 8, 2018
e588862
Fixed issue
andrebriggs Nov 8, 2018
617732c
Changed query formatting in some areas
andrebriggs Nov 8, 2018
6dfaa30
Changes to enforce Tagging_User as a key in the CLI config
andrebriggs Nov 9, 2018
ed65c3f
Merge branch 'master' of https://github.com/andrebriggs/active-learni…
andrebriggs Nov 9, 2018
eb843d7
Merge remote-tracking branch 'upstream/master'
andrebriggs Nov 9, 2018
ff40fcb
Merge remote-tracking branch 'upstream/master'
andrebriggs Nov 12, 2018
333de6c
Merge remote-tracking branch 'upstream/master'
andrebriggs Nov 13, 2018
2e4dcc5
Merge remote-tracking branch 'upstream/master'
andrebriggs Nov 14, 2018
4a5409d
Merge remote-tracking branch 'upstream/master'
andrebriggs Nov 15, 2018
593f69e
Revised teh way we do user tracking.
andrebriggs Nov 15, 2018
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
8 changes: 4 additions & 4 deletions functions/pipeline/download/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

image_count = int(req.params.get('imageCount'))
user_id = int(req.params.get('userId'))
user_name = req.params.get('userName')

# setup response object
headers = {
"content-type": "application/json"
}
if not user_id:
if not user_name:
return func.HttpResponse(
status_code=401,
headers=headers,
body=json.dumps({"error": "invalid userId given or omitted"})
body=json.dumps({"error": "invalid userName given or omitted"})
)
elif not image_count:
return func.HttpResponse(
Expand All @@ -34,7 +34,7 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
try:
# DB configuration
data_access = ImageTagDataAccess(get_postgres_provider())

user_id = data_access.create_user(user_name)
image_urls = list(data_access.get_new_images(image_count, user_id))

# TODO: Populate starting json with tags, if any exist... (precomputed or retagging?)
Expand Down
22 changes: 11 additions & 11 deletions functions/pipeline/onboarding/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import logging
import json
import azure.functions as func

from ..shared.db_provider import get_postgres_provider
Expand All @@ -13,10 +14,14 @@
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

user_id = req.params.get('userId')
user_name = req.params.get('userName')

if not user_id:
return func.HttpResponse("userId query parameter invalid or omitted", status_code=401)
if not user_name:
return func.HttpResponse(
status_code=401,
headers={ "content-type": "application/json"},
body=json.dumps({"error": "invalid userName given or omitted"})
)

try:
req_body = req.get_json()
Expand Down Expand Up @@ -49,16 +54,11 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
image_object_list.append(image)

# TODO: Wrap db access section in try/catch, send an appropriate http response in the event of an error
logging.info("Now connecting to database...")
data_access = ImageTagDataAccess(get_postgres_provider())
logging.info("Connected.")

# Create user id
user_id_number = data_access.create_user(user_id)
logging.info("User id for {0} is {1}".format(user_id, str(user_id_number)))
user_id = data_access.create_user(user_name)

# Add new images to the database, and retrieve a dictionary ImageId's mapped to ImageUrl's
image_id_url_map = data_access.add_new_images(image_object_list,user_id_number)
image_id_url_map = data_access.add_new_images(image_object_list,user_id)

# Print out dictionary for debugging
logging.info("Image ID and URL map dictionary:")
Expand Down Expand Up @@ -119,7 +119,7 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
update_urls_dictionary[image_id] = permanent_storage_path

logging.info("Now updating permanent URLs in the DB...")
data_access.update_image_urls(update_urls_dictionary, user_id_number)
data_access.update_image_urls(update_urls_dictionary, user_id)
logging.info("Done.")

# Construct response string of permanent URLs
Expand Down
2 changes: 1 addition & 1 deletion functions/pipeline/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
azure-functions==1.0.0a5
azure-functions-worker==1.0.0a6
azure-storage
azure-storage-blob==1.4.0
grpcio==1.14.2
grpcio-tools==1.14.2
protobuf==3.6.1
Expand Down
15 changes: 10 additions & 5 deletions functions/pipeline/upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
# TODO: Create if check for userId and valid json checks?
vott_json = req.get_json()
upload_data = process_vott_json(vott_json)
user_id = int(req.params.get('userId'))
upload_data['userId'] = user_id
user_name = req.params.get('userName')

if not user_name:
return func.HttpResponse(
status_code=401,
headers={ "content-type": "application/json"},
body=json.dumps({"error": "invalid userName given or omitted"})
)

# DB configuration
data_access = ImageTagDataAccess(get_postgres_provider())
user_id = data_access.create_user(user_name)

# Update tagged images
ids_to_tags = upload_data["imageIdToTags"]
Expand All @@ -45,9 +52,7 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse(
body=json.dumps(upload_data),
status_code=200,
headers={
"content-type": "application/json"
}
headers={ "content-type": "application/json"},
)
except Exception as e:
return func.HttpResponse(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
azure-functions==1.0.0a5
azure-functions-worker==1.0.0a6
azure-storage
azure-storage-blob==1.4.0
grpcio==1.14.2
grpcio-tools==1.14.2
protobuf==3.6.1
Expand Down