Skip to content

Commit

Permalink
Merge pull request #316 from HuongNV13/support_python_mlbackend
Browse files Browse the repository at this point in the history
Support Python Machine learning backend
  • Loading branch information
lameze authored Feb 27, 2025
2 parents f0f774f + 1bc4d73 commit 1c4c1a4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ jobs:
- { branch: MOODLE_311_STABLE, php: "8.0", database: mysql, suite: phpunit }
- { branch: MOODLE_310_STABLE, php: "7.4", database: mysql, suite: phpunit }
- { branch: MOODLE_39_STABLE, php: "7.4", database: mysql, suite: phpunit }
- { branch: main, php: "8.3", database: oracle, suite: phpunit }
- { branch: MOODLE_405_STABLE, php: "8.3", database: oracle, suite: phpunit }
- { branch: MOODLE_404_STABLE, php: "8.3", database: oracle, suite: phpunit }
- { branch: MOODLE_403_STABLE, php: "8.2", database: oracle, suite: phpunit }
Expand Down Expand Up @@ -195,7 +194,6 @@ jobs:
- { branch: MOODLE_311_STABLE, php: "8.0", database: mysql, browser: chrome, suite: behat }
- { branch: MOODLE_310_STABLE, php: "7.4", database: mysql, browser: firefox, suite: behat }
- { branch: MOODLE_39_STABLE, php: "7.4", database: mysql, browser: chrome, suite: behat }
- { branch: main, php: "8.3", database: oracle, browser: firefox, suite: behat }
- { branch: MOODLE_405_STABLE, php: "8.3", database: oracle, browser: chrome, suite: behat }
- { branch: MOODLE_404_STABLE, php: "8.3", database: oracle, browser: chrome, suite: behat }
- { branch: MOODLE_403_STABLE, php: "8.2", database: oracle, browser: chrome, suite: behat }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-c
| `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no | any value | not set | If set, dependencies for memcached, redis, solr, and openldap are added |
| `MOODLE_DOCKER_BBB_MOCK` | no | any value | not set | If set the BigBlueButton mock image is started and configured |
| `MOODLE_DOCKER_MATRIX_MOCK` | no | any value | not set | If set the Matrix mock image is started and configured |
| `MOODLE_DOCKER_MLBACKEND` | no | any value | not set | If set the Python Machine Learning image is started and configured |
| `MOODLE_DOCKER_BEHAT_FAILDUMP` | no | Path on your file system | not set | Behat faildumps are already available at http://localhost:8000/_/faildumps/ by default, this allows for mapping a specific filesystem folder to retrieve the faildumps in bulk / automated ways |
| `MOODLE_DOCKER_DB_PORT` | no | any integer value | none | If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all). Username is "moodle" (or "sa" for mssql) and password is "m@0dl3ing". |
| `MOODLE_DOCKER_WEB_HOST` | no | any valid hostname | localhost | The hostname for web |
Expand Down
6 changes: 6 additions & 0 deletions bin/moodle-docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ then
dockercompose="${dockercompose} -f ${basedir}/matrix-mock.yml"
fi

# Machine Learning backend
if [[ ! -z "$MOODLE_DOCKER_MLBACKEND" ]];
then
dockercompose="${dockercompose} -f ${basedir}/mlbackend.yml"
fi

# Faildump directory
if [[ ! -z "$MOODLE_DOCKER_BEHAT_FAILDUMP" ]];
then
Expand Down
4 changes: 4 additions & 0 deletions bin/moodle-docker-compose.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ IF NOT "%MOODLE_DOCKER_MATRIX_MOCK%"=="" (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\matrix-mock.yml"
)

IF NOT "%MOODLE_DOCKER_MLBACKEND%"=="" (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\mlbackend.yml"
)

IF NOT "%MOODLE_DOCKER_BEHAT_FAILDUMP%"=="" (
IF NOT EXIST "%MOODLE_DOCKER_BEHAT_FAILDUMP%" (
ECHO Error: MOODLE_DOCKER_BEHAT_FAILDUMP is not an existing directory
Expand Down
7 changes: 7 additions & 0 deletions config.docker-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,11 @@
define('TEST_COMMUNICATION_MATRIX_MOCK_SERVER', "http://matrixmock/{$mockhash}");
}

if (getenv('MOODLE_DOCKER_MLBACKEND')) {
define('TEST_MLBACKEND_PYTHON_HOST', 'mlbackendpython');
define('TEST_MLBACKEND_PYTHON_PORT', 5000);
define('TEST_MLBACKEND_PYTHON_USERNAME', 'default');
define('TEST_MLBACKEND_PYTHON_PASSWORD', 'sshhhh');
}

require_once(__DIR__ . '/lib/setup.php');
6 changes: 6 additions & 0 deletions mlbackend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
webserver:
environment:
MOODLE_DOCKER_MLBACKEND: "true"
mlbackendpython:
image: moodlehq/moodle-mlbackend-python:3.0.5-python3.7.5
1 change: 1 addition & 0 deletions tests/phpunit-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ then
elif [ "$SUITE" = "phpunit-full" ];
then
export MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES=true
export MOODLE_DOCKER_MLBACKEND=true
initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/phpunit/cli/init.php"
else
echo "Error, unknown suite '$SUITE'"
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ then
testcmd="bin/moodle-docker-compose exec -T webserver vendor/bin/phpunit --filter core_dml_testcase"
elif [ "$SUITE" = "phpunit-full" ];
then
testcmd="bin/moodle-docker-compose exec -T webserver vendor/bin/phpunit --verbose"
testcmd="bin/moodle-docker-compose exec -T webserver vendor/bin/phpunit"
else
echo "Error, unknown suite '$SUITE'"
exit 1
Expand Down

0 comments on commit 1c4c1a4

Please sign in to comment.