Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
cd2203eb
Commit
cd2203eb
authored
Sep 28, 2016
by
Adam
Committed by
GitHub
Sep 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13521 from edx/adam/update-dump-neo4j-command
set neo4j configuration at the command line
parents
4c56c242
23986796
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
39 deletions
+48
-39
lms/djangoapps/courseware/management/commands/dump_to_neo4j.py
+33
-9
lms/djangoapps/courseware/management/commands/tests/test_dump_to_neo4j.py
+15
-11
lms/envs/aws.py
+0
-4
lms/envs/common.py
+0
-5
lms/envs/test.py
+0
-10
No files found.
lms/djangoapps/courseware/management/commands/dump_to_neo4j.py
View file @
cd2203eb
...
...
@@ -139,7 +139,22 @@ class ModuleStoreSerializer(object):
class
Command
(
BaseCommand
):
"""
Command to dump modulestore data to neo4j
Takes the following named arguments:
host: the host of the neo4j server
port: the port on the server that accepts https requests
user: the username for the neo4j user
password: the user's password
Example usage:
python manage.py lms dump_to_neo4j --host localhost --port 7473
\
--user user --password password --settings=aws
"""
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'--host'
,
type
=
unicode
)
parser
.
add_argument
(
'--port'
,
type
=
int
)
parser
.
add_argument
(
'--user'
,
type
=
unicode
)
parser
.
add_argument
(
'--password'
,
type
=
unicode
)
@staticmethod
def
add_to_transaction
(
neo4j_entities
,
transaction
):
...
...
@@ -156,16 +171,25 @@ class Command(BaseCommand):
Iterates through each course, serializes them into graphs, and saves
those graphs to neo4j.
"""
# first, make sure that there's a valid neo4j configuration
if
settings
.
NEO4J_CONFIG
is
None
:
raise
CommandError
(
"No neo4j configuration (NEO4J_CONFIG) defined in lms.auth.json."
)
auth_params
=
[
"{host}:{https_port}"
,
"{user}"
,
"{password}"
]
authenticate
(
*
[
param
.
format
(
**
settings
.
NEO4J_CONFIG
)
for
param
in
auth_params
])
host
=
options
[
'host'
]
port
=
options
[
'port'
]
neo4j_user
=
options
[
'user'
]
neo4j_password
=
options
[
'password'
]
authenticate
(
"{host}:{port}"
.
format
(
host
=
host
,
port
=
port
),
neo4j_user
,
neo4j_password
,
)
graph
=
Graph
(
**
settings
.
NEO4J_CONFIG
)
graph
=
Graph
(
bolt
=
True
,
password
=
neo4j_password
,
user
=
neo4j_user
,
https_port
=
port
,
host
=
host
,
secure
=
True
)
mss
=
ModuleStoreSerializer
()
...
...
lms/djangoapps/courseware/management/commands/tests/test_dump_to_neo4j.py
View file @
cd2203eb
...
...
@@ -36,6 +36,7 @@ class TestDumpToNeo4jCommandBase(SharedModuleStoreTestCase):
cls
.
course2
=
CourseFactory
.
create
()
@ddt.ddt
class
TestDumpToNeo4jCommand
(
TestDumpToNeo4jCommandBase
):
"""
Tests for the dump to neo4j management command
...
...
@@ -50,7 +51,13 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
mock_transaction
=
mock
.
Mock
()
mock_graph
.
begin
.
return_value
=
mock_transaction
call_command
(
'dump_to_neo4j'
)
call_command
(
'dump_to_neo4j'
,
host
=
'mock_host'
,
port
=
7473
,
user
=
'mock_user'
,
password
=
'mock_password'
,
)
self
.
assertEqual
(
mock_graph
.
begin
.
call_count
,
2
)
self
.
assertEqual
(
mock_transaction
.
commit
.
call_count
,
2
)
...
...
@@ -72,21 +79,18 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
mock_graph
.
begin
.
return_value
=
mock_transaction
mock_transaction
.
run
.
side_effect
=
ValueError
(
'Something went wrong!'
)
call_command
(
'dump_to_neo4j'
)
call_command
(
'dump_to_neo4j'
,
host
=
'mock_host'
,
port
=
7473
,
user
=
'mock_user'
,
password
=
'mock_password'
,
)
self
.
assertEqual
(
mock_graph
.
begin
.
call_count
,
2
)
self
.
assertEqual
(
mock_transaction
.
commit
.
call_count
,
0
)
self
.
assertEqual
(
mock_transaction
.
rollback
.
call_count
,
2
)
@mock.patch
(
'django.conf.settings.NEO4J_CONFIG'
,
None
)
def
test_dump_to_neo4j_no_config
(
self
):
"""
Tests that the command errors out if there isn't a configuration
file found
"""
with
self
.
assertRaises
(
CommandError
):
call_command
(
'dump_to_neo4j'
)
@ddt.ddt
class
TestModuleStoreSerializer
(
TestDumpToNeo4jCommandBase
):
...
...
lms/envs/aws.py
View file @
cd2203eb
...
...
@@ -871,10 +871,6 @@ APP_UPGRADE_CACHE_TIMEOUT = ENV_TOKENS.get('APP_UPGRADE_CACHE_TIMEOUT', APP_UPGR
AFFILIATE_COOKIE_NAME
=
ENV_TOKENS
.
get
(
'AFFILIATE_COOKIE_NAME'
,
AFFILIATE_COOKIE_NAME
)
############## Settings for Neo4j ############################
NEO4J_CONFIG
=
AUTH_TOKENS
.
get
(
'NEO4J_CONFIG'
)
############## Settings for LMS Context Sensitive Help ##############
DOC_LINK_BASE_URL
=
ENV_TOKENS
.
get
(
'DOC_LINK_BASE_URL'
,
DOC_LINK_BASE_URL
)
lms/envs/common.py
View file @
cd2203eb
...
...
@@ -2974,11 +2974,6 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id'
REDIRECT_CACHE_TIMEOUT
=
None
# The length of time we cache Redirect model data
REDIRECT_CACHE_KEY_PREFIX
=
'redirects'
############## Settings for Neo4j ############################
# This should be set in configuration
NEO4J_CONFIG
=
None
############## Settings for LMS Context Sensitive Help ##############
DOC_LINK_BASE_URL
=
None
lms/envs/test.py
View file @
cd2203eb
...
...
@@ -592,13 +592,3 @@ COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes", REPO_ROOT / "common/test"]
COMPREHENSIVE_THEME_LOCALE_PATHS
=
[
REPO_ROOT
/
"themes/conf/locale"
,
]
LMS_ROOT_URL
=
"http://localhost:8000"
# Test configuration for neo4j
NEO4J_CONFIG
=
{
'bolt'
:
True
,
'password'
:
'password'
,
'user'
:
'neo4j'
,
'https_port'
:
7473
,
'host'
:
'localhost'
,
'secure'
:
True
,
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment