Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tenet
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Tetras MARS
tenet
Commits
76ced0b3
Commit
76ced0b3
authored
2 years ago
by
David Rouquet
Browse files
Options
Downloads
Patches
Plain Diff
multiproc stuff
parent
7646baa7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tenet/main.py
+23
-9
23 additions, 9 deletions
tenet/main.py
with
23 additions
and
9 deletions
tenet/main.py
+
23
−
9
View file @
76ced0b3
...
@@ -13,7 +13,7 @@ from rdflib import Graph
...
@@ -13,7 +13,7 @@ from rdflib import Graph
import
logging
import
logging
import
logging.config
import
logging.config
import
multiprocessing_logging
import
multiprocessing_logging
from
multiprocessing
import
Pool
import
multiprocessing
from
extraction
import
config
,
structure
,
process
from
extraction
import
config
,
structure
,
process
from
utility.timer
import
timed
from
utility.timer
import
timed
...
@@ -166,6 +166,16 @@ def create_ontology_from_amrld_file(amrld_file_path,
...
@@ -166,6 +166,16 @@ def create_ontology_from_amrld_file(amrld_file_path,
return
ontology_turtle_string
return
ontology_turtle_string
global
result_triple_queue
def
pool_function
(
sentence_indice
,
sentence_file_list
):
sentence_file
=
sentence_file_list
[
sentence_indice
]
logger
.
info
(
f
'
*** sentence
{
sentence_indice
}
***
'
)
config
.
sentence_output_dir
=
f
'
-
{
sentence_indice
}
'
new_triple_list
=
__apply_extraction
(
config
,
sentence_file
)
# The following must handled via a global queue
result_triple_list
.
extend
(
new_triple_list
)
@timed
@timed
def
create_ontology_from_amrld_dir
(
amrld_dir_path
,
def
create_ontology_from_amrld_dir
(
amrld_dir_path
,
...
@@ -173,7 +183,7 @@ def create_ontology_from_amrld_dir(amrld_dir_path,
...
@@ -173,7 +183,7 @@ def create_ontology_from_amrld_dir(amrld_dir_path,
onto_prefix
=
None
,
onto_prefix
=
None
,
out_file_path
=
None
,
out_file_path
=
None
,
technical_dir_path
=
None
,
technical_dir_path
=
None
,
processes
=
1
processes
=
multiprocessing
.
cpu_count
()
-
1
):
):
"""
"""
Method to create an ontology (as Turtle String) from a transduction
Method to create an ontology (as Turtle String) from a transduction
...
@@ -212,13 +222,17 @@ def create_ontology_from_amrld_dir(amrld_dir_path,
...
@@ -212,13 +222,17 @@ def create_ontology_from_amrld_dir(amrld_dir_path,
sentence_dir
=
config
.
source_sentence_file
sentence_dir
=
config
.
source_sentence_file
sentence_count
=
0
sentence_count
=
0
result_triple_list
=
[]
result_triple_list
=
[]
#@@ Support for multiprecessing mus be done here
for
sentence_file
in
glob
.
glob
(
sentence_dir
,
recursive
=
True
):
result_triple_queue
=
multiprocessing
.
Queue
()
sentence_count
+=
1
sentence_file_list
=
glob
.
glob
(
sentence_dir
,
recursive
=
True
)
logger
.
info
(
f
'
*** sentence
{
sentence_count
}
***
'
)
config
.
sentence_output_dir
=
f
'
-
{
sentence_count
}
'
# The following is for multiprocessing logging (must be exec before the pool is created
new_triple_list
=
__apply_extraction
(
config
,
sentence_file
)
multiprocessing_logging
.
install_mp_handler
()
result_triple_list
.
extend
(
new_triple_list
)
star_iterable
=
[(
i
,
sentence_file_list
)
for
i
in
range
(
len
(
sentence_file_list
))]
with
multiprocessing
.
Pool
(
processes
)
as
p
:
p
.
starmap
(
pool_function
,
star_iterable
)
# -- Final Ontology Generation (factoid_graph)
# -- Final Ontology Generation (factoid_graph)
logger
.
info
(
'
\n
=== Final Ontology Generation ===
'
)
logger
.
info
(
'
\n
=== Final Ontology Generation ===
'
)
...
...
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