Skip to content

Commit

Permalink
Merge pull request #7 from plotly/dds-deploy
Browse files Browse the repository at this point in the history
Change storage solution from bucketeer to gcp
  • Loading branch information
ycaokris committed May 3, 2019
2 parents b303bbe + 435694c commit b1a8089
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
25 changes: 17 additions & 8 deletions app.py
Expand Up @@ -24,9 +24,9 @@
app = dash.Dash(__name__)
server = app.server

# Heroku Conditions
if 'DYNO' in os.environ:
# Change caching to redis if hosted on heroku

if 'REDIS_URL' in os.environ:
# Change caching to redis if hosted on dds
cache_config = {
'CACHE_TYPE': 'redis',
'CACHE_REDIS_URL': os.environ["REDIS_URL"],
Expand All @@ -45,13 +45,16 @@
'CACHE_DIR': 'cache-directory',
}

# S3 Client for Bucketeer. It is used to store user images. The bucket name
# S3 Client. It is used to store user images. The bucket name
# is stored inside the utils file, the key is
# the session id generated by uuid
access_key_id = os.environ.get('BUCKETEER_AWS_ACCESS_KEY_ID')
secret_access_key = os.environ.get('BUCKETEER_AWS_SECRET_ACCESS_KEY')
bucket_name = os.environ.get('BUCKETEER_BUCKET_NAME')
s3 = boto3.client('s3', aws_access_key_id=access_key_id,
access_key_id = os.environ.get('ACCESS_KEY_ID')
secret_access_key = os.environ.get('SECRET_ACCESS_KEY')
bucket_name = os.environ.get('BUCKET_NAME')

s3 = boto3.client('s3',
endpoint_url="https://storage.googleapis.com",
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key)

# Caching
Expand Down Expand Up @@ -294,13 +297,19 @@ def apply_actions_on_image(session_id,
if len(action_stack) == 0:
# Retrieve the url in which the image string is stored inside s3,
# using the session ID

url = s3.generate_presigned_url(
ClientMethod='get_object',
Params={
'Bucket': bucket_name,
'Key': session_id
}
)

# A key replacement is required for URL pre-sign in gcp

url = url.replace('AWSAccessKeyId', 'GoogleAccessId')

response = requests.get(url)
print(len(response.text))
im_pil = drc.b64_to_pil(response.text)
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Expand Up @@ -2,13 +2,13 @@ dash==0.36.0
dash-html-components==0.13.5
dash-core-components==0.43.0
dash-renderer==0.17.0
numpy==1.14.3
pandas==0.20.3
numpy==1.16.3
pandas==0.24.2
plotly==2.7.0
flask==1.0.1
gunicorn==19.8.1
scipy==1.0.1
pillow==5.1.0
scipy==1.2.1
pillow==6.0.0
Flask-Caching==1.4.0
redis==2.10.6
boto3==1.7.48
Expand Down
1 change: 0 additions & 1 deletion utils.py
Expand Up @@ -5,7 +5,6 @@
import dash_reusable_components as drc
from PIL import Image, ImageFilter, ImageDraw, ImageEnhance

BUCKET_NAME = 'bucketeer-dash-image-processing'

# [filename, image_signature, action_stack]
STORAGE_PLACEHOLDER = json.dumps({
Expand Down

0 comments on commit b1a8089

Please sign in to comment.