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
23986796
Commit
23986796
authored
Sep 20, 2016
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set neo4j configuration at the command line
parent
20fc5bae
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 @
23986796
...
@@ -139,7 +139,22 @@ class ModuleStoreSerializer(object):
...
@@ -139,7 +139,22 @@ class ModuleStoreSerializer(object):
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
"""
"""
Command to dump modulestore data to neo4j
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
@staticmethod
def
add_to_transaction
(
neo4j_entities
,
transaction
):
def
add_to_transaction
(
neo4j_entities
,
transaction
):
...
@@ -156,16 +171,25 @@ class Command(BaseCommand):
...
@@ -156,16 +171,25 @@ class Command(BaseCommand):
Iterates through each course, serializes them into graphs, and saves
Iterates through each course, serializes them into graphs, and saves
those graphs to neo4j.
those graphs to neo4j.
"""
"""
# first, make sure that there's a valid neo4j configuration
host
=
options
[
'host'
]
if
settings
.
NEO4J_CONFIG
is
None
:
port
=
options
[
'port'
]
raise
CommandError
(
neo4j_user
=
options
[
'user'
]
"No neo4j configuration (NEO4J_CONFIG) defined in lms.auth.json."
neo4j_password
=
options
[
'password'
]
)
authenticate
(
auth_params
=
[
"{host}:{https_port}"
,
"{user}"
,
"{password}"
]
"{host}:{port}"
.
format
(
host
=
host
,
port
=
port
),
authenticate
(
*
[
param
.
format
(
**
settings
.
NEO4J_CONFIG
)
for
param
in
auth_params
])
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
()
mss
=
ModuleStoreSerializer
()
...
...
lms/djangoapps/courseware/management/commands/tests/test_dump_to_neo4j.py
View file @
23986796
...
@@ -36,6 +36,7 @@ class TestDumpToNeo4jCommandBase(SharedModuleStoreTestCase):
...
@@ -36,6 +36,7 @@ class TestDumpToNeo4jCommandBase(SharedModuleStoreTestCase):
cls
.
course2
=
CourseFactory
.
create
()
cls
.
course2
=
CourseFactory
.
create
()
@ddt.ddt
class
TestDumpToNeo4jCommand
(
TestDumpToNeo4jCommandBase
):
class
TestDumpToNeo4jCommand
(
TestDumpToNeo4jCommandBase
):
"""
"""
Tests for the dump to neo4j management command
Tests for the dump to neo4j management command
...
@@ -50,7 +51,13 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
...
@@ -50,7 +51,13 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
mock_transaction
=
mock
.
Mock
()
mock_transaction
=
mock
.
Mock
()
mock_graph
.
begin
.
return_value
=
mock_transaction
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_graph
.
begin
.
call_count
,
2
)
self
.
assertEqual
(
mock_transaction
.
commit
.
call_count
,
2
)
self
.
assertEqual
(
mock_transaction
.
commit
.
call_count
,
2
)
...
@@ -72,21 +79,18 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
...
@@ -72,21 +79,18 @@ class TestDumpToNeo4jCommand(TestDumpToNeo4jCommandBase):
mock_graph
.
begin
.
return_value
=
mock_transaction
mock_graph
.
begin
.
return_value
=
mock_transaction
mock_transaction
.
run
.
side_effect
=
ValueError
(
'Something went wrong!'
)
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_graph
.
begin
.
call_count
,
2
)
self
.
assertEqual
(
mock_transaction
.
commit
.
call_count
,
0
)
self
.
assertEqual
(
mock_transaction
.
commit
.
call_count
,
0
)
self
.
assertEqual
(
mock_transaction
.
rollback
.
call_count
,
2
)
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
@ddt.ddt
class
TestModuleStoreSerializer
(
TestDumpToNeo4jCommandBase
):
class
TestModuleStoreSerializer
(
TestDumpToNeo4jCommandBase
):
...
...
lms/envs/aws.py
View file @
23986796
...
@@ -871,10 +871,6 @@ APP_UPGRADE_CACHE_TIMEOUT = ENV_TOKENS.get('APP_UPGRADE_CACHE_TIMEOUT', APP_UPGR
...
@@ -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
)
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 ##############
############## Settings for LMS Context Sensitive Help ##############
DOC_LINK_BASE_URL
=
ENV_TOKENS
.
get
(
'DOC_LINK_BASE_URL'
,
DOC_LINK_BASE_URL
)
DOC_LINK_BASE_URL
=
ENV_TOKENS
.
get
(
'DOC_LINK_BASE_URL'
,
DOC_LINK_BASE_URL
)
lms/envs/common.py
View file @
23986796
...
@@ -2979,11 +2979,6 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id'
...
@@ -2979,11 +2979,6 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id'
REDIRECT_CACHE_TIMEOUT
=
None
# The length of time we cache Redirect model data
REDIRECT_CACHE_TIMEOUT
=
None
# The length of time we cache Redirect model data
REDIRECT_CACHE_KEY_PREFIX
=
'redirects'
REDIRECT_CACHE_KEY_PREFIX
=
'redirects'
############## Settings for Neo4j ############################
# This should be set in configuration
NEO4J_CONFIG
=
None
############## Settings for LMS Context Sensitive Help ##############
############## Settings for LMS Context Sensitive Help ##############
DOC_LINK_BASE_URL
=
None
DOC_LINK_BASE_URL
=
None
lms/envs/test.py
View file @
23986796
...
@@ -592,13 +592,3 @@ COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes", REPO_ROOT / "common/test"]
...
@@ -592,13 +592,3 @@ COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes", REPO_ROOT / "common/test"]
COMPREHENSIVE_THEME_LOCALE_PATHS
=
[
REPO_ROOT
/
"themes/conf/locale"
,
]
COMPREHENSIVE_THEME_LOCALE_PATHS
=
[
REPO_ROOT
/
"themes/conf/locale"
,
]
LMS_ROOT_URL
=
"http://localhost:8000"
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