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

Suggested improvements #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
celery = "*"
gunicorn = "*"
django = "*"
django-heroku = "*"
django-crispy-forms = "*"
requests = "*"
django-open-humans = "*"
redis = "*"

[requires]
python_version = "3.6"
224 changes: 224 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SECRET_KEY='secretgoeshere'
OPENHUMANS_CLIENT_ID='clientidhere'
OPENHUMANS_CLIENT_SECRET='clientsecrethere'

# Set if you want to test against local version of main site
# OPENHUMANS_OH_BASE_URL='http://127.0.0.1:8000'

# Set if you want another redis URL
# REDIS_URL='redis://'
10 changes: 2 additions & 8 deletions loggather/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@

import os

from env_tools import apply_env

import django_heroku


# Apply the env in the .env file
apply_env()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Expand All @@ -22,7 +17,7 @@
DEBUG = True if os.getenv("DEBUG", "true").lower() == "true" else False


ALLOWED_HOSTS = ["*"]
ALLOWED_HOSTS = []

ROOT_URLCONF = "loggather.urls"

Expand Down Expand Up @@ -124,9 +119,8 @@
OPENHUMANS_OH_BASE_URL = os.getenv(
"OPENHUMANS_OH_BASE_URL", "https://www.openhumans.org"
)
OHAPI_OH_BASE_URL = OPENHUMANS_OH_BASE_URL

CELERY_BROKER_URL = os.getenv("REDIS_URL")
CELERY_BROKER_URL = os.getenv("REDIS_URL", "redis://")
CELERY_TASK_SERIALIZER = "json"

LOGIN_URL = "/"
Expand Down
10 changes: 4 additions & 6 deletions loggather/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
logger = get_task_logger(__name__)


def serialize_accesslogs(api_endpoint, oh_member, access_token, start_date, end_date):
def serialize_accesslogs(api_endpoint, oh_member, start_date, end_date):
"""
Groups logs by project, then converts from dict to csv, and finally uploads the
resultant csv files to aws.
Expand Down Expand Up @@ -132,14 +132,13 @@ def serialize_accesslogs(api_endpoint, oh_member, access_token, start_date, end_
csv = "{0}\n{1}".format(",".join(headers), csv) # Prepend the headers
f = io.StringIO(csv)
logger.info("Writing {0}".format(filename))
upload_stream(
oh_member.upload(
f,
filename,
metadata={
"description": "Open Humans access logs: AWS side",
"tags": ["logs", "access logs", "AWS access logs"],
},
access_token=access_token,
)


Expand All @@ -149,12 +148,11 @@ def get_logs(oh_member_pk, start_date=None, end_date=None):
Celery task to retrieve the specified set of logs and save them as files
"""
oh_member = OpenHumansMember.objects.get(pk=oh_member_pk)
access_token = oh_member.get_access_token()
serialize_accesslogs(
"newdatafileaccesslog", oh_member, access_token, start_date, end_date
"newdatafileaccesslog", oh_member, start_date, end_date
)
serialize_accesslogs(
"awsdatafileaccesslog", oh_member, access_token, start_date, end_date
"awsdatafileaccesslog", oh_member, start_date, end_date
)

return
12 changes: 0 additions & 12 deletions requirements.in

This file was deleted.

37 changes: 0 additions & 37 deletions requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion runtime.txt

This file was deleted.