Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
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-analytics-data-api
Commits
f0196c12
Commit
f0196c12
authored
May 05, 2014
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add verbose option to SqoopImportFromMysql
Change-Id: Ifa66f0cd3534132d94715d4214c8dc35132e0b60
parent
3929cee0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
3 deletions
+16
-3
edx/analytics/tasks/database_exports.py
+4
-1
edx/analytics/tasks/sqoop.py
+5
-0
edx/analytics/tasks/tests/test_sqoop.py
+7
-2
No files found.
edx/analytics/tasks/database_exports.py
View file @
f0196c12
...
@@ -114,11 +114,13 @@ class StudentModulePerCourseAfterImportWorkflow(StudentModulePerCourseTask):
...
@@ -114,11 +114,13 @@ class StudentModulePerCourseAfterImportWorkflow(StudentModulePerCourseTask):
credentials: Path to the external access credentials file.
credentials: Path to the external access credentials file.
num_mappers: The number of map tasks to ask Sqoop to use.
num_mappers: The number of map tasks to ask Sqoop to use.
where: A 'where' clause to be passed to Sqoop.
where: A 'where' clause to be passed to Sqoop.
verbose: Sqoop prints more information while working.
"""
"""
credentials
=
luigi
.
Parameter
()
# TODO: move to config
credentials
=
luigi
.
Parameter
()
# TODO: move to config
num_mappers
=
luigi
.
Parameter
(
default
=
None
)
# TODO: move to config
num_mappers
=
luigi
.
Parameter
(
default
=
None
)
# TODO: move to config
where
=
luigi
.
Parameter
(
default
=
None
)
where
=
luigi
.
Parameter
(
default
=
None
)
verbose
=
luigi
.
BooleanParameter
(
default
=
False
)
def
requires
(
self
):
def
requires
(
self
):
return
SqoopImportFromMysql
(
return
SqoopImportFromMysql
(
...
@@ -126,5 +128,6 @@ class StudentModulePerCourseAfterImportWorkflow(StudentModulePerCourseTask):
...
@@ -126,5 +128,6 @@ class StudentModulePerCourseAfterImportWorkflow(StudentModulePerCourseTask):
destination
=
self
.
dump_root
,
destination
=
self
.
dump_root
,
table_name
=
'courseware_studentmodule'
,
table_name
=
'courseware_studentmodule'
,
num_mappers
=
self
.
num_mappers
,
num_mappers
=
self
.
num_mappers
,
where
=
self
.
where
where
=
self
.
where
,
verbose
=
self
.
verbose
)
)
edx/analytics/tasks/sqoop.py
View file @
f0196c12
...
@@ -37,6 +37,7 @@ class SqoopImportTask(luigi.hadoop.BaseHadoopJobTask):
...
@@ -37,6 +37,7 @@ class SqoopImportTask(luigi.hadoop.BaseHadoopJobTask):
where: A 'where' clause to be passed to Sqoop. Note that
where: A 'where' clause to be passed to Sqoop. Note that
no spaces should be embedded and special characters should
no spaces should be embedded and special characters should
be escaped. For example: --where "id
\
<50".
be escaped. For example: --where "id
\
<50".
verbose: Print more information while working.
Example Credentials File::
Example Credentials File::
...
@@ -54,6 +55,7 @@ class SqoopImportTask(luigi.hadoop.BaseHadoopJobTask):
...
@@ -54,6 +55,7 @@ class SqoopImportTask(luigi.hadoop.BaseHadoopJobTask):
table_name
=
luigi
.
Parameter
()
table_name
=
luigi
.
Parameter
()
num_mappers
=
luigi
.
Parameter
(
default
=
None
)
num_mappers
=
luigi
.
Parameter
(
default
=
None
)
where
=
luigi
.
Parameter
(
default
=
None
)
where
=
luigi
.
Parameter
(
default
=
None
)
verbose
=
luigi
.
BooleanParameter
(
default
=
False
)
def
requires
(
self
):
def
requires
(
self
):
return
{
return
{
...
@@ -81,6 +83,9 @@ class SqoopImportTask(luigi.hadoop.BaseHadoopJobTask):
...
@@ -81,6 +83,9 @@ class SqoopImportTask(luigi.hadoop.BaseHadoopJobTask):
url
=
self
.
connection_url
(
cred
)
url
=
self
.
connection_url
(
cred
)
generic_args
=
[
'--connect'
,
url
,
'--username'
,
cred
[
'username'
]]
generic_args
=
[
'--connect'
,
url
,
'--username'
,
cred
[
'username'
]]
if
self
.
verbose
:
generic_args
.
append
(
'--verbose'
)
# write password to temp file object, and pass name of file to Sqoop:
# write password to temp file object, and pass name of file to Sqoop:
with
password_target
.
open
(
'w'
)
as
password_file
:
with
password_target
.
open
(
'w'
)
as
password_file
:
password_file
.
write
(
cred
[
'password'
])
password_file
.
write
(
cred
[
'password'
])
...
...
edx/analytics/tasks/tests/test_sqoop.py
View file @
f0196c12
...
@@ -26,7 +26,7 @@ class SqoopImportFromMysqlTestCase(unittest.TestCase):
...
@@ -26,7 +26,7 @@ class SqoopImportFromMysqlTestCase(unittest.TestCase):
self
.
mock_run
=
patcher2
.
start
()
self
.
mock_run
=
patcher2
.
start
()
self
.
addCleanup
(
patcher2
.
stop
)
self
.
addCleanup
(
patcher2
.
stop
)
def
run_task
(
self
,
credentials
=
None
,
num_mappers
=
None
,
where
=
None
):
def
run_task
(
self
,
credentials
=
None
,
num_mappers
=
None
,
where
=
None
,
verbose
=
False
):
"""
"""
Emulate execution of a generic MysqlTask.
Emulate execution of a generic MysqlTask.
"""
"""
...
@@ -45,7 +45,8 @@ class SqoopImportFromMysqlTestCase(unittest.TestCase):
...
@@ -45,7 +45,8 @@ class SqoopImportFromMysqlTestCase(unittest.TestCase):
destination
=
"/fake/destination"
,
destination
=
"/fake/destination"
,
table_name
=
"example_table"
,
table_name
=
"example_table"
,
num_mappers
=
num_mappers
,
num_mappers
=
num_mappers
,
where
=
where
where
=
where
,
verbose
=
verbose
)
)
fake_input
=
{
fake_input
=
{
...
@@ -92,6 +93,10 @@ class SqoopImportFromMysqlTestCase(unittest.TestCase):
...
@@ -92,6 +93,10 @@ class SqoopImportFromMysqlTestCase(unittest.TestCase):
self
.
assertEquals
(
arglist
,
expected_arglist
)
self
.
assertEquals
(
arglist
,
expected_arglist
)
self
.
assertTrue
(
self
.
mock_hdfstarget
()
.
remove
.
called
)
self
.
assertTrue
(
self
.
mock_hdfstarget
()
.
remove
.
called
)
def
test_verbose_arguments
(
self
):
arglist
=
self
.
run_task
(
verbose
=
True
)
self
.
assertIn
(
'--verbose'
,
arglist
)
def
test_connect_with_where_args
(
self
):
def
test_connect_with_where_args
(
self
):
arglist
=
self
.
run_task
(
where
=
'id < 50'
)
arglist
=
self
.
run_task
(
where
=
'id < 50'
)
self
.
assertEquals
(
arglist
[
-
4
],
'--where'
)
self
.
assertEquals
(
arglist
[
-
4
],
'--where'
)
...
...
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