Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cosy-Bio
Drugst.One
backend
Commits
2c794a7b
Commit
2c794a7b
authored
2 years ago
by
AndiMajore
Browse files
Options
Downloads
Patches
Plain Diff
fixed json download
parent
6c864713
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drugstone/views.py
+17
-6
17 additions, 6 deletions
drugstone/views.py
with
17 additions
and
6 deletions
drugstone/views.py
+
17
−
6
View file @
2c794a7b
...
...
@@ -467,11 +467,6 @@ def graph_export(request) -> Response:
G
=
nx
.
Graph
()
node_map
=
dict
()
for
node
in
nodes
:
# drugstone_id is not interesting outside of drugstone
# try:
# del node['drugstone_id']
# except KeyError:
# pass
# networkx does not support datatypes such as lists or dicts
for
key
in
list
(
node
.
keys
()):
if
isinstance
(
node
[
key
],
list
)
or
isinstance
(
node
[
key
],
dict
):
...
...
@@ -506,7 +501,23 @@ def graph_export(request) -> Response:
data
=
nx
.
generate_graphml
(
G
)
response
=
HttpResponse
(
data
,
content_type
=
'
application/xml
'
)
elif
fmt
==
'
json
'
:
data
=
json
.
dumps
(
nx
.
readwrite
.
json_graph
.
node_link_data
(
G
))
data
=
nx
.
readwrite
.
json_graph
.
node_link_data
(
G
)
del
data
[
'
graph
'
]
del
data
[
'
multigraph
'
]
remove_node_properties
=
[
'
color
'
,
'
shape
'
,
'
border_width
'
,
'
group_name
'
,
'
border_width_selected
'
,
'
shadow
'
,
'
group_id
'
,
'
drugstone_type
'
,
'
font
'
]
remove_edge_properties
=
[
'
group_name
'
,
'
color
'
,
'
dashes
'
,
'
shadow
'
,
'
id
'
]
for
node
in
data
[
'
nodes
'
]:
for
prop
in
remove_node_properties
:
if
prop
in
node
:
del
node
[
prop
]
for
edge
in
data
[
'
links
'
]:
for
prop
in
remove_edge_properties
:
if
prop
in
edge
:
del
edge
[
prop
]
data
[
"
edges
"
]
=
data
.
pop
(
"
links
"
)
data
=
json
.
dumps
(
data
)
data
=
data
.
replace
(
'"
{
'
,
'
{
'
).
replace
(
'
}
"'
,
'
}
'
).
replace
(
'"
[
'
,
'
[
'
).
replace
(
'
]
"'
,
'
]
'
).
replace
(
'
\\
"'
,
'"'
)
response
=
HttpResponse
(
data
,
content_type
=
'
application/json
'
)
elif
fmt
==
'
csv
'
:
data
=
pd
.
DataFrame
(
nx
.
to_numpy_array
(
G
),
columns
=
G
.
nodes
(),
index
=
G
.
nodes
())
...
...
This diff is collapsed.
Click to expand it.
Maier, Andreas
@bba1660
mentioned in commit
a82ff2e0
·
1 year ago
mentioned in commit
a82ff2e0
mentioned in commit a82ff2e0f27d70cf13361feae56c2429f268fbf0
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment