Giter VIP home page Giter VIP logo

edx-analytics-data-api's Introduction

edX Analytics API Server

DEPRECATION NOTICE

The Insights product and associated repositories are in the process of being deprecated and removed from service. Details on the deprecation status and process can be found in the relevant Github issue <https://github.com/openedx/public-engineering/issues/221>_.

This repository may be archived and moved to the openedx-unsupported Github organization at any time.

The following sections are for historical purposes only.


This repository includes the Django server for the API as well as the API package itself. The client is hosted at https://github.com/openedx/edx-analytics-data-api-client.

The enterprise client is hosted at https://github.com/openedx/frontend-app-admin-portal.

License

The code in this repository is licensed under version 3 of the AGPL unless otherwise noted.

Please see LICENSE.txt for details.

Getting Started With Devstack

The best way to run this service is with edX Devstack: https://github.com/openedx/devstack.

See the Devstack Readme for information on how to install and run devstack.

With devstack running and this repo checked-out locally, you'll want to do the following from your devstack directory:

$ make dev.pull.analyticsapi
$ make dev.up.analyticsapi
$ make dev.provision.analyticsapi     # this will provision the DB user, run migrations, etc.
$ docker-compose restart analyticsapi # maybe necessary to reset the DB connection
$ make analyticsapi-logs              # make sure the app is running without errors

Getting Started Standalone (deprecated, prefer running in devstack)

  1. Create a virtual environment and activate it.

  2. Install the requirements:

    $ make develop
    
  3. Setup the databases:

    $ make migrate-all
    

    The learner API endpoints require elasticsearch with a mapping defined on this wiki page. The connection to elasticsearch can be configured by the ELASTICSEARCH_LEARNERS_HOST and ELASTICSEARCH_LEARNERS_INDEX django settings. To run tests locally use:

    $ make test
    

    This will launch an Elasticsearch Docker container for the tests. To simply run the container without starting the tests, run:

    $ make test.run_elasticsearch
    

    To stop an Elasticsearch Docker container, run:

    $ make test.stop_elasticsearch
    
  4. Create a user and authentication token. Note that the user will be created if one does not exist.

    $ ./manage.py set_api_key <username> <token>
    
  5. Run the server:

    $ ./manage.py runserver
    

Development with edx-enterprise-data

If you need to make changes to edx-enterprise-data and have them reflected when you run the edx-analytics-data-api server, you can follow these steps. If you do not intend to make changes to edx-enterprise-data, you can skip this section.

Devstack Development

#. Clone the edx-enterprise-data repo into the src folder alongside your devstack workspace on the host system. #. The modified edx-enterprise-data repository will now be available to devstack containers at /edx/src/edx-enterprise-data. #. Inside the edx-data-analytics-api container run pip install `-e /edx/src/edx-enterprise-data`

Standalone Development

  1. Recommended: Install this repo into a subfolder of your working directory. Within that subfolder create an src folder.
  2. Clone the edx-enterprise-data repo into the src folder.
  3. cd into your edx-data-analytics-api folder and activate your virtualenv.
  4. Run pip install -e ./src/edx-enterprise-data.
  5. Run the server as per instructions above. Changes to edx-enterprise-data should be picked up by the server.

Loading Data

The fixtures directory contains demo data and the generate_fake_enrollment_data management command can generate enrollment data. Run the command below to load/generate this data in the database.

$ make loaddata

Additional management commands for creating data can be found in edx-enterprise-data

Loading Video Data

The above command should work fine on its own, but you may see warnings about video ids:

WARNING:analyticsdataserver.clients:Course Blocks API failed to return
video ids (401). See README for instructions on how to authenticate the
API with your local LMS.

In order to generate video data, the API has to be authenticated with your local LMS so that it can access the video ids for each course. Instead of adding a whole OAuth client to the API for this one procedure, we will piggyback off of the Insights OAuth client by taking the OAuth token it generates and using it here.

  1. Start your local LMS server. (e.g. in devstack, run paver devstack --fast lms).

  2. If your local LMS server is running on any address other than the default of http://localhost:18000/, make sure to add this setting to analyticsdataserver/settings/local.py with the correct URL. (you will likely not need to do this):

    # Don't forget to add the trailing forward slash
    LMS_BASE_URL = 'http://example.com:18000/'
    
  3. Sign into your local Insights server making sure to use your local LMS for authentication. This will generate a new OAuth access token if you do not already have one that isn't expired.

    The user you sign in with must have staff access to the courses for which you want generated video data.

  4. Visit your local LMS server's admin site (by default, this is at http://localhost:18000/admin).

  5. Sign in with a superuser account. Don't have one? Make one with this command in your devstack as the edxapp user:

    $ edxapp@precise64:~/edx-platform$ ./manage.py lms createsuperuser
    

    Enter a username and password that you will remember.

  6. On the admin site, find the "Django OAuth Toolkit" section and click the link "Access tokens". The breadcrumbs should show "Home > Django OAuth Toolkit > Access tokens".

    Copy the string in the "Token" column for the first row in the table. Also, make sure the "User" of the first row is the same user that you signed in with in step 3.

  7. Paste the string as a new setting in analyticsdataserver/settings/local.py:

    COURSE_BLOCK_API_AUTH_TOKEN = '<paste access token here>'
    
  8. Run make loaddata again and ensure that you see the following log message in the output:

    INFO:analyticsdataserver.clients:Successfully authenticated with the
    Course Blocks API.
    
  9. Check if you now have video data in the API. Either by querying the API in the swagger docs at /docs/#!/api/Videos_List_GET, or visiting the Insights engagement/videos/ page for a course.

Note: the access tokens expire in one year so you should only have to follow the above steps once a year.

Running Tests

Run make validate install the requirements, run the tests, and run lint.

edx-analytics-data-api's People

Contributors

alangsto avatar ashultz0 avatar brittneyexline avatar christopappas avatar clintonb avatar cpennington avatar dan-f avatar dsjen avatar dylanrhodes avatar edx-requirements-bot avatar feanil avatar georgebabey avatar hammadahmadwaqas avatar irfanuddinahmad avatar jarv avatar jawayria avatar kdmccormick avatar macdiesel avatar mhoeber avatar michaelroytman avatar muhammad-ammar avatar mulby avatar robrap avatar rocha avatar saleem-latif avatar schenedx avatar syedimranhassan avatar thallada avatar usamasadiq avatar zacharis278 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edx-analytics-data-api's Issues

Switch to Ansible-free Docker image

In order to advance implementation of both OEP-45: Configuring and Operating Open edX and deprecation of the configuration repository, we would like to switch devstack from using primarily Docker images built with Ansible code from the configuration repository to images built from Dockerfiles in each service's repository. We hope this will also help simplify Tutor by providing better base images to derive from, with fewer workarounds and duplicated code blocks required in Tutor.

A/C

  • Ensure that the repo's Dockerfile can create a base image which is appropriate for small production installations
  • Ensure that the repo's Dockerfile also defines an additional image derived from the base which adds dependencies and configuration changes needed for development environments
  • Check with the Tutor developers during code review to see if any further changes to the Dockerfile would help simplify Tutor
  • Automate uploads of both images when code changes are merged
  • Switch devstack to use the new Ansible-free development image, and do some basic testing to ensure it works before merging

Elasticsearch document is not public

The elastic search document is not public. I don't have access and thus can't finish setting up the data API.

Please provide access or suggest an alternative.

@thallada @dsjen I noticed that you guys are working actively on this repo I would appreciate if you can help.

Replace MemcachedCache backend with PymemcacheCache in analytics-api

The django.core.cache.backends.memcached.MemcachedCache backend is removed so we now are replacing this with PymemcacheCache in all of our IDAs, so we need to replace this for analytics-api also.

This service is deployed with GoCD.

https://docs.djangoproject.com/en/4.2/releases/4.1/#features-removed-in-4-1

Things to be done:

  • First, add pymemcache dependency in the codebase and move it to PROD
  • Update the relevant configs for sandbox in sandbox-internal
  • Update the relevant configs for stage in edx-internal
  • Update the relevant configs for prod in edx-internal
  • Update the relevant configs for edge in edge-internal
  • Update the configs in related codebase so that the docker images of that service also get updated

These are the config related changes which we will do:


One more thing to add:

  • The IDA/services which are using edx-django-utils as their direct-dependency. We will enable edx_django_utils.cache.disable_forced_cache_miss_for_none waffle switch for them from their admin panel link to doc

Upgrade pylintrc via edx-lint

Currently I am unable to update pylintrc to the generated version defined in edx_lint because it was previously manually edited. And also not touched since 2020 ๐Ÿ˜ฑ

Work should be done to upgrade pylintrc properly and resolve the errors that happen because of the upgrade.

https://github.com/openedx/edx-lint

How to load data from lms to analytic

Hi,
I am installing openEdx on local with devstack. Currently I have implemented lms, cms, but as of analytic data api, I am currently having some problems:

  • On the doc there is make loaddata to generate_fake_course_data
    However I want to get the actual value in lms, how about?
    Hope everyone answers?

Django 4.2 Upgrade

Description

Under the effort of Django 4.2 Upgrade, complete all of the following steps to complete the upgrade.

  • Update tox & Github action workflow using modernisers to add support for Django 4.2
  • Remove any versions of Python earlier than 3.8 from tox.ini, and GitHub Actions workflows.
  • Update the pinned Django version in the requirements to Django==4.2
  • Run make upgrade to update all dependencies for Django 4.2.
  • Run and verify all tests are passing in the CI for both Django 4.2 and Django 3.2 to contain backward compatibility.
  • Run available code-mods to fix the failing tests.
  • Add conditional checks wherever needed to still have support for Django 3.2.
  • Update the repo support field in the IDA Upgrade Sheet.

Add Django 4.2 in CI in analytics-api

In order to have support for Django 4.2, we first need to run tests on Django 4.2 in the analytics-api service. For updating CI, we should run tox and GitHub actions modernizers.

Tox Modernizer: tox_moderniser_django42.py

Github Action Modernizer: github_actions_modernizer_django42.py

### A/C
- [ ] Run tests with Django 4.2
- [ ] Fix all test failures with Django 4.2 (if any)
- [ ] After merging, ask the owning squad to add Django 4.2 tests in branch protection rules

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.