Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
d8ead269
Commit
d8ead269
authored
Apr 29, 2017
by
Stefane Fermigier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format.
parent
2fe0efa9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
51 deletions
+54
-51
olapy/core/mdx/executor/execute.py
olapy/core/mdx/executor/execute.py
+2
-3
olapy/core/mdx/tools/config_file_parser.py
olapy/core/mdx/tools/config_file_parser.py
+3
-3
olapy/core/mdx/tools/connection.py
olapy/core/mdx/tools/connection.py
+1
-0
olapy/core/mdx/tools/models.py
olapy/core/mdx/tools/models.py
+3
-0
olapy/core/services/models.py
olapy/core/services/models.py
+2
-3
olapy/core/services/xmla.py
olapy/core/services/xmla.py
+5
-8
olapy/core/services/xmla_discover_tools.py
olapy/core/services/xmla_discover_tools.py
+26
-21
olapy/core/services/xmla_execute_tools.py
olapy/core/services/xmla_execute_tools.py
+8
-8
setup.py
setup.py
+2
-3
tests/test_xmla_notox.py
tests/test_xmla_notox.py
+2
-2
No files found.
olapy/core/mdx/executor/execute.py
View file @
d8ead269
...
@@ -5,8 +5,8 @@ from __future__ import absolute_import, division, print_function
...
@@ -5,8 +5,8 @@ from __future__ import absolute_import, division, print_function
import
itertools
import
itertools
import
os
import
os
import
re
import
re
from
os.path
import
expanduser
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
os.path
import
expanduser
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
...
@@ -730,8 +730,7 @@ class MdxEngine:
...
@@ -730,8 +730,7 @@ class MdxEngine:
self.execute_one_tuple(tupl, start_df,
self.execute_one_tuple(tupl, start_df,
columns_to_keep.values()))
columns_to_keep.values()))
cols = list(
cols = list(itertools.chain.from_iterable(columns_to_keep.values()))
itertools.chain.from_iterable(columns_to_keep.values()))
# TODO BUG !!! https://github.com/pandas-dev/pandas/issues/15525
# TODO BUG !!! https://github.com/pandas-dev/pandas/issues/15525
# solution 1 .astype(str) ( take a lot of time from execution)
# solution 1 .astype(str) ( take a lot of time from execution)
...
...
olapy/core/mdx/tools/config_file_parser.py
View file @
d8ead269
...
@@ -4,10 +4,11 @@ import os
...
@@ -4,10 +4,11 @@ import os
from
lxml
import
etree
from
lxml
import
etree
from
.models
import
Cube
,
Facts
,
Dimension
from
.models
import
Cube
,
Dimension
,
Facts
class
ConfigParser
:
class
ConfigParser
:
def
__init__
(
self
,
cube_path
,
file_name
=
'cubes-config.xml'
):
def
__init__
(
self
,
cube_path
,
file_name
=
'cubes-config.xml'
):
self
.
cube_path
=
cube_path
self
.
cube_path
=
cube_path
self
.
file_name
=
file_name
self
.
file_name
=
file_name
...
@@ -57,8 +58,7 @@ class ConfigParser:
...
@@ -57,8 +58,7 @@ class ConfigParser:
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
keys
=
{
keys
=
{
key
.
text
:
key
.
attrib
[
'ref'
]
key
.
text
:
key
.
attrib
[
'ref'
]
for
key
in
xml_facts
.
findall
(
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
'keys/column_name'
)
},
},
measures
=
[
measures
=
[
mes
.
text
mes
.
text
...
...
olapy/core/mdx/tools/connection.py
View file @
d8ead269
...
@@ -2,6 +2,7 @@ import psycopg2 as pg
...
@@ -2,6 +2,7 @@ import psycopg2 as pg
class
MyDB
(
object
):
class
MyDB
(
object
):
def
__init__
(
self
,
def
__init__
(
self
,
username
=
'postgres'
,
username
=
'postgres'
,
password
=
'root'
,
password
=
'root'
,
...
...
olapy/core/mdx/tools/models.py
View file @
d8ead269
class
Facts
:
class
Facts
:
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
__dict__
.
update
(
kwargs
)
self
.
__dict__
.
update
(
kwargs
)
...
@@ -7,6 +8,7 @@ class Facts:
...
@@ -7,6 +8,7 @@ class Facts:
class
Dimension
:
class
Dimension
:
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
__dict__
.
update
(
kwargs
)
self
.
__dict__
.
update
(
kwargs
)
...
@@ -15,6 +17,7 @@ class Dimension:
...
@@ -15,6 +17,7 @@ class Dimension:
class
Cube
:
class
Cube
:
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
__dict__
.
update
(
kwargs
)
self
.
__dict__
.
update
(
kwargs
)
...
...
olapy/core/services/models.py
View file @
d8ead269
...
@@ -5,6 +5,7 @@ from spyne.model.fault import Fault
...
@@ -5,6 +5,7 @@ from spyne.model.fault import Fault
class
Tuple
(
object
):
class
Tuple
(
object
):
def
__init__
(
self
,
Hierarchy
,
UName
,
Caption
,
LName
,
LNum
,
DisplayInfo
,
def
__init__
(
self
,
Hierarchy
,
UName
,
Caption
,
LName
,
LNum
,
DisplayInfo
,
PARENT_UNIQUE_NAME
,
HIERARCHY_UNIQUE_NAME
,
Value
):
PARENT_UNIQUE_NAME
,
HIERARCHY_UNIQUE_NAME
,
Value
):
self
.
Hierarchy
=
Hierarchy
self
.
Hierarchy
=
Hierarchy
...
@@ -92,9 +93,7 @@ class Propertielist(ComplexModel):
...
@@ -92,9 +93,7 @@ class Propertielist(ComplexModel):
class
Command
(
ComplexModel
):
class
Command
(
ComplexModel
):
_type_info
=
{
_type_info
=
{
'Statement'
:
Unicode
,}
'Statement'
:
Unicode
,
}
class
ExecuteRequest
(
ComplexModel
):
class
ExecuteRequest
(
ComplexModel
):
...
...
olapy/core/services/xmla.py
View file @
d8ead269
...
@@ -13,9 +13,8 @@ from spyne.protocol.soap import Soap11
...
@@ -13,9 +13,8 @@ from spyne.protocol.soap import Soap11
from
spyne.server.wsgi
import
WsgiApplication
from
spyne.server.wsgi
import
WsgiApplication
from
..mdx.tools.config_file_parser
import
ConfigParser
from
..mdx.tools.config_file_parser
import
ConfigParser
from
..services.models
import
DiscoverRequest
,
ExecuteRequest
,
Session
\
from
..services.models
import
DiscoverRequest
# , AuthenticationError
# , AuthenticationError
from
..services.models
import
ExecuteRequest
,
Session
from
.xmla_discover_tools
import
XmlaDiscoverTools
from
.xmla_discover_tools
import
XmlaDiscoverTools
from
.xmla_execute_tools
import
XmlaExecuteTools
from
.xmla_execute_tools
import
XmlaExecuteTools
from
.xmla_execute_xsds
import
execute_xsd
from
.xmla_execute_xsds
import
execute_xsd
...
@@ -45,7 +44,7 @@ class XmlaProviderService(ServiceBase):
...
@@ -45,7 +44,7 @@ class XmlaProviderService(ServiceBase):
_out_header
=
Session
,
_out_header
=
Session
,
_throws
=
InvalidCredentialsError
_throws
=
InvalidCredentialsError
# _throws=AuthenticationError
# _throws=AuthenticationError
)
)
def
Discover
(
ctx
,
request
):
def
Discover
(
ctx
,
request
):
"""
"""
the first principle function of xmla protocol
the first principle function of xmla protocol
...
@@ -105,8 +104,7 @@ class XmlaProviderService(ServiceBase):
...
@@ -105,8 +104,7 @@ class XmlaProviderService(ServiceBase):
return
discover_tools
.
discover_mdschema_measures__response
(
request
)
return
discover_tools
.
discover_mdschema_measures__response
(
request
)
elif
request
.
RequestType
==
"MDSCHEMA_DIMENSIONS"
:
elif
request
.
RequestType
==
"MDSCHEMA_DIMENSIONS"
:
return
discover_tools
.
discover_mdschema_dimensions_response
(
return
discover_tools
.
discover_mdschema_dimensions_response
(
request
)
request
)
elif
request
.
RequestType
==
"MDSCHEMA_HIERARCHIES"
:
elif
request
.
RequestType
==
"MDSCHEMA_HIERARCHIES"
:
return
discover_tools
.
discover_mdschema_hierarchies_response
(
return
discover_tools
.
discover_mdschema_hierarchies_response
(
...
@@ -124,8 +122,7 @@ class XmlaProviderService(ServiceBase):
...
@@ -124,8 +122,7 @@ class XmlaProviderService(ServiceBase):
request
)
request
)
elif
request
.
RequestType
==
"MDSCHEMA_PROPERTIES"
:
elif
request
.
RequestType
==
"MDSCHEMA_PROPERTIES"
:
return
discover_tools
.
discover_mdschema_properties_response
(
return
discover_tools
.
discover_mdschema_properties_response
(
request
)
request
)
elif
request
.
RequestType
==
"MDSCHEMA_MEMBERS"
:
elif
request
.
RequestType
==
"MDSCHEMA_MEMBERS"
:
return
discover_tools
.
discover_mdschema_members_response
(
request
)
return
discover_tools
.
discover_mdschema_members_response
(
request
)
...
...
olapy/core/services/xmla_discover_tools.py
View file @
d8ead269
...
@@ -7,14 +7,19 @@ import uuid
...
@@ -7,14 +7,19 @@ import uuid
from
lxml
import
etree
from
lxml
import
etree
from
..mdx.executor.execute
import
MdxEngine
from
..mdx.executor.execute
import
MdxEngine
from
.xmla_discover_xsds
import
(
from
.xmla_discover_xsds
import
(
dbschema_catalogs_xsd
,
dbschema_tables_xsd
,
dbschema_catalogs_xsd
,
dbschema_tables_xsd
,
discover_datasources_xsd
,
discover_datasources_xsd
,
discover_literals_xsd
,
discover_preperties_xsd
,
discover_literals_xsd
,
discover_schema_rowsets_xsd
,
mdschema_cubes_xsd
,
mdschema_dimensions_xsd
,
discover_preperties_xsd
,
mdschema_hierarchies_xsd
,
mdschema_kpis_xsd
,
mdschema_levels_xsd
,
discover_schema_rowsets_xsd
,
mdschema_measures_xsd
,
mdschema_measuresgroups_dimensions_xsd
,
mdschema_cubes_xsd
,
mdschema_dimensions_xsd
,
mdschema_measuresgroups_xsd
,
mdschema_members_xsd
,
mdschema_hierarchies_xsd
,
mdschema_kpis_xsd
,
mdschema_properties_PROPERTIES_xsd
,
mdschema_sets_xsd
)
mdschema_levels_xsd
,
mdschema_measures_xsd
,
mdschema_measuresgroups_dimensions_xsd
,
mdschema_measuresgroups_xsd
,
mdschema_members_xsd
,
mdschema_properties_PROPERTIES_xsd
,
mdschema_sets_xsd
)
# TODO clean
# TODO clean
...
@@ -73,6 +78,7 @@ class XmlaDiscoverTools():
...
@@ -73,6 +78,7 @@ class XmlaDiscoverTools():
</return>"""
)
</return>"""
)
def
discover_properties_response
(
self
,
request
):
def
discover_properties_response
(
self
,
request
):
def
get_props
(
xsd
,
PropertyName
,
PropertyDescription
,
PropertyType
,
def
get_props
(
xsd
,
PropertyName
,
PropertyDescription
,
PropertyType
,
PropertyAccessType
,
IsRequired
,
Value
):
PropertyAccessType
,
IsRequired
,
Value
):
return
etree
.
fromstring
(
"""
return
etree
.
fromstring
(
"""
...
@@ -114,15 +120,15 @@ class XmlaDiscoverTools():
...
@@ -114,15 +120,15 @@ class XmlaDiscoverTools():
elif
request
.
Restrictions
.
RestrictionList
.
PropertyName
==
'MdpropMdxSubqueries'
:
elif
request
.
Restrictions
.
RestrictionList
.
PropertyName
==
'MdpropMdxSubqueries'
:
if
'Unspecified'
in
request
.
Properties
.
PropertyList
.
Catalog
:
if
'Unspecified'
in
request
.
Properties
.
PropertyList
.
Catalog
:
return
get_props
(
discover_preperties_xsd
,
return
get_props
(
discover_preperties_xsd
,
'MdpropMdxSubqueries'
,
'MdpropMdxSubqueries'
,
'
MdpropMdxSubqueries
'
,
'MdpropMdxSubqueries'
,
'
int'
,
'Read'
,
'false
'
,
'
int'
,
'Read'
,
'false'
,
'
15'
)
'15'
)
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
if
request
.
Properties
.
PropertyList
.
Catalog
is
not
None
:
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
self
.
change_catalogue
(
request
.
Properties
.
PropertyList
.
Catalog
)
return
get_props
(
discover_preperties_xsd
,
return
get_props
(
discover_preperties_xsd
,
'MdpropMdxSubqueries'
,
'MdpropMdxSubqueries'
,
'
MdpropMdxSubqueries
'
,
'MdpropMdxSubqueries'
,
'
int'
,
'Read'
,
'false
'
,
'
int'
,
'Read'
,
'false'
,
'
15'
)
'15'
)
elif
request
.
Restrictions
.
RestrictionList
.
PropertyName
==
'MdpropMdxDrillFunctions'
:
elif
request
.
Restrictions
.
RestrictionList
.
PropertyName
==
'MdpropMdxDrillFunctions'
:
if
'Unspecified'
in
request
.
Properties
.
PropertyList
.
Catalog
:
if
'Unspecified'
in
request
.
Properties
.
PropertyList
.
Catalog
:
...
@@ -2268,8 +2274,8 @@ class XmlaDiscoverTools():
...
@@ -2268,8 +2274,8 @@ class XmlaDiscoverTools():
# joined -> [Product].[Product].[Company]
# joined -> [Product].[Product].[Company]
last_attribut
=
''
.
join
(
att
for
att
in
separed_tuple
[
-
1
]
last_attribut
=
''
.
join
(
att
for
att
in
separed_tuple
[
-
1
]
if
att
not
in
'[]'
).
replace
(
if
att
not
in
'[]'
).
replace
(
'&'
,
'&'
,
'&'
)
'&'
)
return
etree
.
fromstring
(
"""
return
etree
.
fromstring
(
"""
<return>
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
...
@@ -2284,8 +2290,7 @@ class XmlaDiscoverTools():
...
@@ -2284,8 +2290,7 @@ class XmlaDiscoverTools():
<LEVEL_UNIQUE_NAME>{2}</LEVEL_UNIQUE_NAME>
<LEVEL_UNIQUE_NAME>{2}</LEVEL_UNIQUE_NAME>
<LEVEL_NUMBER>0</LEVEL_NUMBER>
<LEVEL_NUMBER>0</LEVEL_NUMBER>
<MEMBER_ORDINAL>0</MEMBER_ORDINAL>
<MEMBER_ORDINAL>0</MEMBER_ORDINAL>
<MEMBER_NAME>"""
+
last_attribut
+
<MEMBER_NAME>"""
+
last_attribut
+
"""</MEMBER_NAME>
"""</MEMBER_NAME>
<MEMBER_UNIQUE_NAME>{3}</MEMBER_UNIQUE_NAME>
<MEMBER_UNIQUE_NAME>{3}</MEMBER_UNIQUE_NAME>
<MEMBER_TYPE>1</MEMBER_TYPE>
<MEMBER_TYPE>1</MEMBER_TYPE>
<MEMBER_CAPTION>"""
+
last_attribut
+
<MEMBER_CAPTION>"""
+
last_attribut
+
...
@@ -2299,6 +2304,6 @@ class XmlaDiscoverTools():
...
@@ -2299,6 +2304,6 @@ class XmlaDiscoverTools():
</row>
</row>
</root>
</root>
</return>
</return>
"""
.
format
(
self
.
selected_catalogue
,
separed_tuple
[
0
],
"""
.
format
(
self
.
selected_catalogue
,
separed_tuple
[
joined
,
request
.
Restrictions
.
RestrictionLi
st
.
0
],
joined
,
reque
st
.
MEMBER_UNIQUE_NAME
))
Restrictions
.
RestrictionList
.
MEMBER_UNIQUE_NAME
))
olapy/core/services/xmla_execute_tools.py
View file @
d8ead269
...
@@ -302,8 +302,8 @@ class XmlaExecuteTools():
...
@@ -302,8 +302,8 @@ class XmlaExecuteTools():
"""
"""
columns_loop
=
[]
columns_loop
=
[]
if
(
len
(
mdx_execution_result
[
'columns_desc'
][
'columns'
].
keys
())
==
0
)
^
(
if
(
len
(
mdx_execution_result
[
'columns_desc'
][
'columns'
].
keys
())
==
0
len
(
mdx_execution_result
[
'columns_desc'
][
'rows'
].
keys
())
==
0
):
)
^
(
len
(
mdx_execution_result
[
'columns_desc'
][
'rows'
].
keys
())
==
0
):
if
self
.
executer
.
facts
in
mdx_execution_result
[
'columns_desc'
][
if
self
.
executer
.
facts
in
mdx_execution_result
[
'columns_desc'
][
'all'
].
keys
():
'all'
].
keys
():
...
@@ -549,12 +549,12 @@ class XmlaExecuteTools():
...
@@ -549,12 +549,12 @@ class XmlaExecuteTools():
tuple
=
""
tuple
=
""
# not used dimensions
# not used dimensions
for
dim_diff
in
list
(
for
dim_diff
in
list
(
set
(
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
))
-
set
(
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
))
-
set
(
set
(
[
[
table_name
table_name
for
table_name
in
mdx_execution_result
[
'columns_desc'
][
for
table_name
in
mdx_execution_result
[
'columns_desc'
][
'all'
]
'all'
]
])):
])):
tuple
+=
"""
tuple
+=
"""
<Member Hierarchy="[{0}].[{0}]">
<Member Hierarchy="[{0}].[{0}]">
<UName>[{0}].[{0}].[{1}].[{2}]</UName>
<UName>[{0}].[{0}].[{1}].[{2}]</UName>
...
...
setup.py
View file @
d8ead269
...
@@ -3,8 +3,8 @@ from __future__ import absolute_import, division, print_function
...
@@ -3,8 +3,8 @@ from __future__ import absolute_import, division, print_function
import
os
import
os
import
zipfile
import
zipfile
from
os.path
import
expanduser
from
os.path
import
expanduser
from
pip.download
import
PipSession
from
pip.download
import
PipSession
from
pip.req
import
parse_requirements
from
pip.req
import
parse_requirements
from
setuptools
import
find_packages
,
setup
from
setuptools
import
find_packages
,
setup
...
@@ -12,8 +12,7 @@ from setuptools import find_packages, setup
...
@@ -12,8 +12,7 @@ from setuptools import find_packages, setup
RUNNING_TOX
=
'RUNTING_TOX'
in
os
.
environ
RUNNING_TOX
=
'RUNTING_TOX'
in
os
.
environ
session
=
PipSession
()
session
=
PipSession
()
_install_requires
=
parse_requirements
(
_install_requires
=
parse_requirements
(
'requirements.txt'
,
session
=
session
)
'requirements.txt'
,
session
=
session
)
install_requires
=
[
str
(
ir
.
req
)
for
ir
in
_install_requires
]
install_requires
=
[
str
(
ir
.
req
)
for
ir
in
_install_requires
]
setup
(
setup
(
...
...
tests/test_xmla_notox.py
View file @
d8ead269
...
@@ -19,6 +19,7 @@ RUNNING_TOX = 'RUNTING_TOX' in os.environ
...
@@ -19,6 +19,7 @@ RUNNING_TOX = 'RUNTING_TOX' in os.environ
class
Member
(
object
):
class
Member
(
object
):
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
__dict__
.
update
(
kwargs
)
self
.
__dict__
.
update
(
kwargs
)
...
@@ -43,8 +44,7 @@ class WSGIServer:
...
@@ -43,8 +44,7 @@ class WSGIServer:
Copy/pasted from pytest_localserver w/ slight changes.
Copy/pasted from pytest_localserver w/ slight changes.
"""
"""
def
__init__
(
self
,
host
=
'127.0.0.1'
,
port
=
8000
,
application
=
None
,
def
__init__
(
self
,
host
=
'127.0.0.1'
,
port
=
8000
,
application
=
None
,
**
kwargs
):
**
kwargs
):
self
.
_server
=
make_server
(
host
,
port
,
application
,
**
kwargs
)
self
.
_server
=
make_server
(
host
,
port
,
application
,
**
kwargs
)
self
.
server_address
=
self
.
_server
.
server_address
self
.
server_address
=
self
.
_server
.
server_address
...
...
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