Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VS2N
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioInsp
VS2N
Commits
1d7f20b8
Commit
1d7f20b8
authored
2 years ago
by
Hammouda Elbez
Browse files
Options
Downloads
Patches
Plain Diff
Synapse module updated
parent
7f592df3
No related branches found
No related tags found
1 merge request
!25
VS2N 0.36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Modules/Neuron/layout.py
+0
-2
0 additions, 2 deletions
src/Modules/Neuron/layout.py
src/Modules/Synapse/spark.py
+7
-11
7 additions, 11 deletions
src/Modules/Synapse/spark.py
with
7 additions
and
13 deletions
src/Modules/Neuron/layout.py
+
0
−
2
View file @
1d7f20b8
...
@@ -69,8 +69,6 @@ class layout(layoutOp):
...
@@ -69,8 +69,6 @@ class layout(layoutOp):
options
=
[{
'
label
'
:
str
(
i
),
'
value
'
:
str
(
i
)}
for
i
in
(
options
=
[{
'
label
'
:
str
(
i
),
'
value
'
:
str
(
i
)}
for
i
in
(
i
for
i
in
self
.
g
.
Layer_Neuron
if
i
!=
"
Input
"
)],
i
for
i
in
self
.
g
.
Layer_Neuron
if
i
!=
"
Input
"
)],
multi
=
False
,
multi
=
False
,
value
=
[{
'
label
'
:
str
(
i
),
'
value
'
:
str
(
i
)}
for
i
in
(
i
for
i
in
self
.
g
.
Layer_Neuron
if
i
!=
"
Input
"
)][
0
][
"
value
"
],
style
=
{
'
width
'
:
'
150px
'
,
"
marginLeft
"
:
"
10px
"
,
"
textAlign
"
:
"
start
"
}),
style
=
{
'
width
'
:
'
150px
'
,
"
marginLeft
"
:
"
10px
"
,
"
textAlign
"
:
"
start
"
}),
dcc
.
Dropdown
(
dcc
.
Dropdown
(
id
=
'
NeuronFilterNeuron
'
,
id
=
'
NeuronFilterNeuron
'
,
...
...
This diff is collapsed.
Click to expand it.
src/Modules/Synapse/spark.py
+
7
−
11
View file @
1d7f20b8
"""
Spark pre-processing operations.
"""
Spark pre-processing operations.
"""
"""
import
pandas
as
pd
import
pymongo
import
pymongo
import
traceback
import
traceback
from
pyspark.sql
import
functions
as
F
from
pyspark.sql
import
functions
as
F
...
@@ -33,23 +34,18 @@ class spark(sparkOp):
...
@@ -33,23 +34,18 @@ class spark(sparkOp):
if
self
.
g
.
sparkSession
==
None
:
if
self
.
g
.
sparkSession
==
None
:
self
.
g
.
createSparkSession
()
self
.
g
.
createSparkSession
()
# --------------------------------------------------
# --------------------------------------------------
df
=
self
.
g
.
sparkSession
.
read
.
format
(
"
com.mongodb.spark.sql
"
)
\
col
=
pymongo
.
collection
.
Collection
(
self
.
g
.
db
,
self
.
DOCUMENT_NAME
)
.
option
(
"
spark.mongodb.input.uri
"
,
self
.
MONGODBURL
+
self
.
g
.
name
+
"
.
"
+
self
.
DOCUMENT_NAME
+
"
?authSource=admin&readPreference=primaryPreferred
"
)
\
globalSynapseWeights
=
col
.
aggregate
([{
"
$sort
"
:
{
"
T
"
:
1
}
},{
"
$group
"
:
{
"
_id
"
:
{
"
To
"
:
'
$To
'
,
"
C
"
:
'
$C
'
,
"
index
"
:
'
$index
'
,
"
L
"
:
'
$L
'
},
"
T
"
:
{
"
$last
"
:
'
$T
'
},
"
V
"
:
{
"
$last
"
:
'
$V
'
}
}
}])
.
option
(
"
pipeline
"
,
"
[{ $sort: { T: 1 } },{$group : { _id : {To:
'
$To
'
, C:
'
$C
'
, index:
'
$index
'
, L:
'
$L
'
}, T : { $last:
'
$T
'
},V : { $last:
'
$V
'
} } }]
"
)
df
=
df
.
load
()
# Data save into MongoDB ---------------------------------
# Data save into MongoDB ---------------------------------
col
=
pymongo
.
collection
.
Collection
(
self
.
g
.
db
,
self
.
OUTPUT_DOCUMENT_NAME
)
df
.
write
.
format
(
"
com.mongodb.spark.sql.DefaultSource
"
)
\
globalSynapseWeights
=
pd
.
DataFrame
(
list
(
globalSynapseWeights
))
.
option
(
"
spark.mongodb.output.uri
"
,
col
.
insert_many
(
globalSynapseWeights
.
to_dict
(
'
records
'
))
self
.
MONGODBURL
+
self
.
g
.
name
+
"
.
"
+
self
.
OUTPUT_DOCUMENT_NAME
+
"
?authSource=admin&readPreference=primaryPreferred
"
).
mode
(
'
append
'
).
save
()
# Indexes creation ---------------------------------------
# Indexes creation ---------------------------------------
print
(
"
Indexes creation (please wait...)
"
)
print
(
"
Indexes creation (please wait...)
"
)
col
=
pymongo
.
collection
.
Collection
(
self
.
g
.
db
,
self
.
OUTPUT_DOCUMENT_NAME
)
col
.
create_index
([(
"
_id.L
"
,
1
)])
col
.
create_index
([(
"
_id.L
"
,
1
)])
col
.
create_index
([(
"
_id
"
,
1
)])
col
.
create_index
([(
"
_id
"
,
1
)])
col
.
create_index
([(
"
_id.To
"
,
1
),(
"
_id.C
"
,
1
)])
col
.
create_index
([(
"
_id.To
"
,
1
),(
"
_id.C
"
,
1
)])
...
...
This diff is collapsed.
Click to expand it.
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