Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# you wish to override

# Set the edx-platform named release. The default release is "hawthorn"
OPENEDX_RELEASE=juniper
OPENEDX_RELEASE=maple

# Env settings TODO
# - PyPI authentication for Twine
15 changes: 4 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: figures tests
on:
push:
branches:
- main
- develop/maple
pull_request:

Expand All @@ -13,16 +12,10 @@ jobs:
strategy:
matrix:
include:
- python: 2.7
tox-env: py27-ginkgo
- python: 2.7
tox-env: py27-hawthorn
- python: 2.7
tox-env: py27-hawthorn_multisite
- python: 3.5
tox-env: py35-juniper_community
- python: 3.5
tox-env: py35-juniper_multisite
- python: 3.8
tox-env: py38-maple_community
- python: 3.8
tox-env: py35-maple_multisite
- python: 3.8
tox-env: lint
- python: 3.8
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
figures/static/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -108,6 +110,9 @@ node_modules
# PyCharm
.idea

# VScode
.vscode

frontend/webpack-stats.json

# Sublime Text
Expand Down
24 changes: 10 additions & 14 deletions DEVELOPER-QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Figures Developer Quickstart Guide

## 1. Overview
Expand All @@ -15,29 +14,28 @@ You should use a Python virtualenv to run Figures standalone development mode. T

Here are links to help guide setting up virtualenv

* https://virtualenv.pypa.io/en/stable/installation/
* https://virtualenv.pypa.io/en/stable/userguide/
* https://docs.python-guide.org/dev/virtualenvs/#lower-level-virtualenv
- https://virtualenv.pypa.io/en/stable/installation/
- https://virtualenv.pypa.io/en/stable/userguide/
- https://docs.python-guide.org/dev/virtualenvs/#lower-level-virtualenv

## 3. Clone Figures, install dependencies, and test

On your development machine, open a terminal (command line shell) and create or navigate to the directory for which you want to install Figures. This will be the parent directory for your Figures project. Example:

**These instructions assume you are running a Python virtualenv**


In the terminal, run the following:

```
git clone https://github.com/appsembler/figures.git
cd figures
pip install -r devsite/requirements/py35_juniper.txt
pip install -r devsite/requirements/community.txt
```

now we'll run [pytest](https://docs.pytest.org/) to make sure that the tests pass:

```
OPENEDX_RELEASE=JUNIPER pytest -c pytest-juniper.ini
pytest
```

## 4. Build front end assets
Expand All @@ -46,7 +44,6 @@ Figures front end assets need to be build from the front end sources. Make sure

Navigate to the `figures/frontend` directory.


Then download JavaScript dependencies:

```
Expand Down Expand Up @@ -110,10 +107,10 @@ _Section incomplete_

Pages of interest:

* http://127.0.0.1:8000/admin/
* http://127.0.0.1:8000/figures/
* http://127.0.0.1:8000/figures/api/
* http://127.0.0.1:8000/admin/figures/
- http://127.0.0.1:8000/admin/
- http://127.0.0.1:8000/figures/
- http://127.0.0.1:8000/figures/api/
- http://127.0.0.1:8000/admin/figures/

## 8. Running the pipeline manually

Expand All @@ -129,7 +126,7 @@ Make sure you have your development virtualenv running. Then navigate to the `de

This will run the pipeline immediately instead of being queued to celery.

*NOTE* The above is just for running the pipeline in Figures standalone mode with the included devsite. If you are working with Figures in Open edX (either devstack or fullstack), run the following:
_NOTE_ The above is just for running the pipeline in Figures standalone mode with the included devsite. If you are working with Figures in Open edX (either devstack or fullstack), run the following:

```
./manage.py lms populate_figures_metrics --no-delay
Expand All @@ -143,7 +140,6 @@ Go to the `frontend` directory and run `yarn`. This will install dependencies

Run `yarn build` to compile the front end assets.


## 10. Running the frontend Webpack server

_TODO: Add this section_
Expand Down
2 changes: 1 addition & 1 deletion devsite/devsite/cans/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import random
import faker

from student.models import UserProfile
from common.djangoapps.student.models import UserProfile


class UserGenerator(object):
Expand Down
20 changes: 10 additions & 10 deletions devsite/devsite/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from django.conf import settings


CELERY_CHECK_MSG_PREFIX = 'figures-devsite-celery-check'
CELERY_CHECK_MSG_PREFIX = "figures-devsite-celery-check"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a problem with the single quotes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I had black enabled at some point. I have disabled it since but looks like I missed some of the changes that were made.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Appreciate that!



# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'devsite.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "devsite.settings")

app = Celery('devsite')
app = Celery("devsite")

# For Celery 4.0+
#
Expand All @@ -25,21 +25,21 @@
# See: https://docs.celeryproject.org/en/4.0/whatsnew-4.0.html
# `app.config_from_object('django.conf:settings', namespace='CELERY')`

app.config_from_object('django.conf:settings')
app.config_from_object("django.conf:settings")


# Load task modules from all registered Django app configs.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


app.conf.update(
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
)
# TODO update django-celery is not needed for celery 4.4.+
# app.conf.update(
# CELERY_RESULT_BACKEND="django-db",
# )


@app.task(bind=True)
def debug_task(self):
print(('Request: {0!r}'.format(self.request)))
print(("Request: {0!r}".format(self.request)))


@app.task(bind=True)
Expand All @@ -49,4 +49,4 @@ def celery_check(self, msg):
Returns a value so that we can test Celery results backend configuration
"""
print(('Called devsite.celery.celery.check with message "{}"'.format(msg)))
return '{prefix}:{msg}'.format(prefix=CELERY_CHECK_MSG_PREFIX, msg=msg)
return "{prefix}:{msg}".format(prefix=CELERY_CHECK_MSG_PREFIX, msg=msg)
2 changes: 1 addition & 1 deletion devsite/devsite/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from figures.compat import StudentModule

from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from student.models import CourseAccessRole, CourseEnrollment, UserProfile
from common.djangoapps.student.models import CourseAccessRole, CourseEnrollment, UserProfile

from organizations.models import Organization, OrganizationCourse

Expand Down
72 changes: 22 additions & 50 deletions devsite/devsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
env = environ.Env(
DEBUG=(bool, True),
ALLOWED_HOSTS=(list, []),
OPENEDX_RELEASE=(str, 'JUNIPER'),
OPENEDX_RELEASE=(str, 'MAPLE'),
FIGURES_IS_MULTISITE=(bool, False),
ENABLE_DEVSITE_CELERY=(bool, True),
ENABLE_OPENAPI_DOCS=(bool, False),
Expand All @@ -35,12 +35,9 @@

OPENEDX_RELEASE = env('OPENEDX_RELEASE').upper()

if OPENEDX_RELEASE == 'GINKGO':
ENABLE_DEVSITE_CELERY = False
else:
ENABLE_DEVSITE_CELERY = env('ENABLE_DEVSITE_CELERY')
ENABLE_DEVSITE_CELERY = env('ENABLE_DEVSITE_CELERY')

MOCKS_DIR = 'mocks/{}'.format(OPENEDX_RELEASE.lower())
MOCKS_DIR = 'mocks/'

# SECURITY WARNING: Use a real key when running in the cloud and keep it secret
SECRET_KEY = 'insecure-secret-key'
Expand Down Expand Up @@ -84,51 +81,25 @@
# Also note the paths set in edx-figures/pytest.ini
'openedx.core.djangoapps.content.course_overviews',
'openedx.core.djangoapps.course_groups',
'student',
'lms.djangoapps.certificates',
'lms.djangoapps.courseware',
'common.djangoapps.student',
]

if ENABLE_DEVSITE_CELERY:
INSTALLED_APPS.append('djcelery')


if OPENEDX_RELEASE == 'GINKGO':
# certificates and courseware do NOT use the `lms.djangoapps.` namespace
# prefix on Ginkgo. See here: https://github.com/appsembler/figures/issues/433
INSTALLED_APPS.append('certificates')
INSTALLED_APPS.append('courseware')
elif OPENEDX_RELEASE == 'HAWTHORN':
# Yes, this is correct, certificates was updated to uses the full namespace
# and courseware has not yet been updated
INSTALLED_APPS.append('lms.djangoapps.certificates')
INSTALLED_APPS.append('courseware')
else:
INSTALLED_APPS.append('lms.djangoapps.certificates')
INSTALLED_APPS.append('lms.djangoapps.courseware')


if OPENEDX_RELEASE == 'JUNIPER':
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
else:
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = 'devsite.urls'

Expand Down Expand Up @@ -183,7 +154,7 @@
}

LOCALE_PATHS = [
os.path.join(PROJECT_ROOT_DIR, 'figures', 'conf', 'locale')
os.path.join(PROJECT_ROOT_DIR, 'figures', 'conf', 'locale')
]


Expand Down Expand Up @@ -243,7 +214,9 @@

# The LMS defines ``ENV_TOKENS`` to load settings declared in `lms.env.json`
# We have an empty dict here to replicate behavior in the LMS
ENV_TOKENS = {}
ENV_TOKENS = {
'FIGURES': {},
}

PRJ_SETTINGS = {
'CELERY_ROUTES': "app.celery.routes"
Expand All @@ -255,7 +228,6 @@
update_celerybeat_schedule(CELERYBEAT_SCHEDULE, ENV_TOKENS, FIGURES_PIPELINE_TASKS_ROUTING_KEY)
update_celery_routes(PRJ_SETTINGS, ENV_TOKENS, FIGURES_PIPELINE_TASKS_ROUTING_KEY)


# Used by Django Debug Toolbar
INTERNAL_IPS = [
'127.0.0.1'
Expand All @@ -266,7 +238,7 @@
'NUM_LEARNERS_PER_COURSE': env('SEED_NUM_LEARNERS_PER_COURSE')
}

ENABLE_OPENAPI_DOCS = env('ENABLE_OPENAPI_DOCS') and OPENEDX_RELEASE not in ['GINKGO', 'HAWTHORN']
ENABLE_OPENAPI_DOCS = env('ENABLE_OPENAPI_DOCS')

if ENABLE_OPENAPI_DOCS:
INSTALLED_APPS += ['drf_yasg2']
INSTALLED_APPS += ['drf_yasg']
31 changes: 12 additions & 19 deletions devsite/devsite/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def root(*args):


env = environ.Env(
OPENEDX_RELEASE=(str, 'JUNIPER'),
OPENEDX_RELEASE=(str, 'MAPLE'),
)

environ.Env.read_env(join(dirname(dirname(__file__)), '.env'))

OPENEDX_RELEASE = env('OPENEDX_RELEASE').upper()

MOCKS_DIR = 'mocks/{}'.format(OPENEDX_RELEASE.lower())
MOCKS_DIR = 'mocks/'

sys.path.append(root('mocks', MOCKS_DIR))

Expand Down Expand Up @@ -73,26 +73,19 @@ def root(*args):
# Also note the paths set in edx-figures/pytest.ini
'openedx.core.djangoapps.content.course_overviews',
'openedx.core.djangoapps.course_groups',
'student',
'common.djangoapps.student',
'organizations'
]

if OPENEDX_RELEASE != 'GINGKO':
INSTALLED_APPS.append('djcelery')

# We need this in order for figures.tasks unit tests to not fail with:
# "error: [Errno 61] Connection refused"
CELERY_ALWAYS_EAGER = True

if OPENEDX_RELEASE == 'GINKGO':
INSTALLED_APPS.append('certificates')
INSTALLED_APPS.append('courseware')
elif OPENEDX_RELEASE == 'HAWTHORN':
INSTALLED_APPS.append('lms.djangoapps.certificates')
INSTALLED_APPS.append('courseware')
else:
INSTALLED_APPS.append('lms.djangoapps.certificates')
INSTALLED_APPS.append('lms.djangoapps.courseware')
# INSTALLED_APPS.append('djcelery')

# We need this in order for figures.tasks unit tests to not fail with:
# "error: [Errno 61] Connection refused"
CELERY_ALWAYS_EAGER = True


INSTALLED_APPS.append('lms.djangoapps.certificates')
INSTALLED_APPS.append('lms.djangoapps.courseware')


TEMPLATES = [
Expand Down
4 changes: 2 additions & 2 deletions devsite/devsite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

if settings.ENABLE_OPENAPI_DOCS:
from rest_framework import permissions
from drf_yasg2.views import get_schema_view
from drf_yasg2 import openapi
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(
title="Figures API",
Expand Down
Loading