Uploaded image for project: 'Moodle QA'
  1. Moodle QA
  2. MDLQA-1 Moodle QA testing
  3. MDLQA-14114

An admin can set up the Python machine learning backend on a separate server

XMLWordPrintable

    • Icon: Functional Test Functional Test
    • Icon: Minor Minor
    • None
    • Original - DO NOT REPORT TEST RESULTS HERE
    • Analytics

      Test environment:

      1. Log in as admin.
      2. Set your correct timezone in 'site administration > Location > Location settings'
      3. Create a new topics course (let's call it "Training") with a start date 1 month ago and an end date in 5 or 10 minutes (basically the time you need to follow the step below).
      4. Enrol 2 users as students in the course, log out as admin and log in as 1 of the students and generate 10 logs or more (e.g. access the course page, access the forum, check participants...) in the course.
      5. Log in as the admin again and create a new topics course (let's call it "Predictions") with a start date 1 month ago and an end date around the end of next month.
      6. Assign 4 users as 'predictions' course students, log in as 2 of these students and generate 10 logs or more (e.g. access the course page, access the forum, check participants...) in the 'predictions' course. 10 logs or more for each student.

      Test 1:

      1. Install the Python package for the machine learning backend on a separate server from the webserver
        • You can do this using the docker image (more info in moodle-mlbackend-python):

          # Note that you need to add --network=moodledocker_default if your are using moodle-docker and you want this container to be visible from the web server.
          docker run -d -p 5000:5000 --name=mlbackendpython --rm --add-host=mlbackendpython:0.0.0.0 moodlehq/moodle-mlbackend-python:3.0.5-python3.7.5
          

        • Alternatively, you can:
          1. Install the Python ML Python on a server you control which is different from the web server running Moodle (if you do not specify any version you will use the latest version, which should be the one we are testing in this QA cycle)

            https://pypi.org/project/moodlemlbackend/

          2. On the same server, start the flask server as described in https://flask.palletsprojects.com/en/1.0.x/quickstart/. In our case that is

            cd /path/where/your/python/package/is/installed
            export FLASK_APP=webapp.py
            export LC_ALL=C.UTF-8
            export LANG=C.UTF-8
            export MOODLE_MLBACKEND_PYTHON_DIR=/path/with/write/permissions/to/store/models
            export MOODLE_MLBACKEND_PYTHON_USERS=default:sshhhh
            flask run
            

      2. Log in as an admin and go to Site administration > Plugins > Machine Learning backend settings > Python machine learning backend.
      3. Tick 'Use a server', set 'Host' to 'mlbackendpython', 'localhost' or '127.0.0.1', the field 'Port' to 5000 and the field 'Password' to 'sshhhh' and save changes.
      4. Go to 'Analytics settings' in the Site administration.
      5. Disable 'Analytics processes execution via command-line only' and select 'Python machine learning backend' for the 'Default predictions processor' field and save changes.
      6. Go to 'Analytics models' in the Site administration.
      7. For 'Students at risk of dropping out' select 'Edit' in the Actions column, tick 'Enabled' and select 'All previous quarters' as 'Analysis interval' and make sure that the Python machine learning backend is set in 'Predictions processor'. Save changes.
      8. Wait until you pass the end date you set in 'Test environment#3', and for 'Students at risk of dropping out' select 'Execute scheduled analysis' in the Actions column.
      9. You should see a green "Training process finished" message and another green "Prediction process finished"
      10. Below the "Training process finished" message there should be a warning: "Analysable Predictions is not valid for this target: The course has not yet finished"
      11. Below the "Prediction process finished" message there should be a warning: "Analysable Training is not valid for this target: Course already finished"

      Test 2 (ML backend using AWS S3)

      1. Create an AWS free account and set up S3
        1. Go to Services > S3 and create a new bucket, the default settings should be fine, save changes. Note the name of the bucket, as you will need it later.
        2. Go to IAM service > add a testuser with 'Programmatic access' > 'Attach existing policies directly' > search for 'AmazonS3FullAccess' permission and select it > No need for tags > Save changes.
        3. Select the user you just created and click on the 'Security credentials' tab to create a new access key and secret (copy them, you will need them below).
      2. If you used the docker image in Test 1 stop it with

        docker stop mlbackendpython 

      3. Install the Python package for the machine learning backend on a separate server from the web server, now using AWS S3 for storage
        • You can do it using the docker image

          # Note that you need to add --network=moodledocker_default if your are using moodle-docker and you want this container to be visible from the web server.
          docker run -d -p 5000:5000 --name=mlbackendpython -e MOODLE_MLBACKEND_PYTHON_S3_BUCKET_NAME=[i-am-a-bucket-name] -e AWS_ACCESS_KEY_ID=[TheKey] -e AWS_SECRET_ACCESS_KEY=[TheSecretKey] --rm --add-host=mlbackendpython:0.0.0.0 moodlehq/moodle-mlbackend-python:3.0.5-python3.7.5 

        • Alternatively, you can:
          1. (if you didn't do it before) Install the Python ML Python on a server you control which is different from the web server running Moodle (if you do not specify any version you will use the latest version, which should be the one we are testing in this QA cycle)

            https://pypi.org/project/moodlemlbackend/

          2. On the same server, stop the flask server if it is still running and start the flask server as described in https://flask.palletsprojects.com/en/1.0.x/quickstart/. Now with

            cd /path/where/your/python/package/is/installed
            export FLASK_APP=webapp.py
            export LC_ALL=C.UTF-8
            export LANG=C.UTF-8
            export MOODLE_MLBACKEND_PYTHON_USERS=default:sshhhh
            export MOODLE_MLBACKEND_PYTHON_S3_BUCKET_NAME=the-bucket-you-created-above
            export AWS_ACCESS_KEY_ID=access-key-in-security-credentials
            export AWS_SECRET_ACCESS_KEY=secret-in-security-credentials
            flask run
            

      4. Log in as an admin and go to 'Analytics models' in the Site administration.
      5. For 'Students at risk of dropping out' select 'Clear predictions' in the Actions column and confirm.
      6. For 'Students at risk of dropping out' select 'Execute scheduled analysis' in the Actions column.
      7. You should see a green "Training process finished" message and another green "Prediction process finished"

            lameze Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.