Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
pipelet
Pipelet
Commits
d0957430
Commit
d0957430
authored
Aug 25, 2010
by
Betoule Marc
Browse files
+ seg relation table
parent
677bb789
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
pipelet/tracker.py
pipelet/tracker.py
+15
-4
pipelet/web.py
pipelet/web.py
+7
-1
No files found.
pipelet/tracker.py
View file @
d0957430
...
...
@@ -149,7 +149,7 @@ class SqliteTracker(Tracker,threading.Thread):
Format is:
TODO
"""
def
__init__
(
self
,
pipe
):
""" Initialize the Sqlite tracker.
...
...
@@ -162,6 +162,8 @@ class SqliteTracker(Tracker,threading.Thread):
## pipeline object
self
.
pipe
=
pipe
self
.
seg_id_cache
=
{}
## string, sql filename
self
.
sqlfile
=
path
.
join
(
pipe
.
_prefix
,
'.sqlstatus'
)
if
self
.
pipe
.
sqlfile
is
not
None
:
...
...
@@ -177,7 +179,7 @@ class SqliteTracker(Tracker,threading.Thread):
self
.
conn
.
execute
(
'create table segments (seg_id INTEGER PRIMARY KEY, seg TEXT, curr_dir TEXT, tag TEXT, comment TEXT)'
)
self
.
conn
.
execute
(
'create table tasks (task_id INTEGER PRIMARY KEY, seg_id INTEGER, status TEXT, input BLOB, output BLOB, str_prod TEXT)'
)
self
.
conn
.
execute
(
'create table task_relations (father_id INTEGER, child_id INTEGER)'
)
self
.
conn
.
execute
(
'create table segment_relations (father_id INTEGER, child_id INTEGER)'
)
self
.
conn
.
row_factory
=
sqlite3
.
Row
self
.
segments_registration
()
...
...
@@ -191,6 +193,7 @@ class SqliteTracker(Tracker,threading.Thread):
def
segments_registration
(
self
):
"""
"""
previous
=
None
for
s
in
self
.
pipe
.
flatten
():
curr_dir
=
self
.
pipe
.
get_curr_dir
(
s
)
try
:
...
...
@@ -201,12 +204,20 @@ class SqliteTracker(Tracker,threading.Thread):
seg_id
=
self
.
conn
.
execute
(
'select seg_id from segments where curr_dir = ? limit 1'
,
(
curr_dir
,)).
fetchone
()[
0
]
self
.
seg_id_cache
[
s
]
=
seg_id
logger
.
info
(
"Segment %s instance (%s) already registered in db."
%
(
s
,
curr_dir
))
except
TypeError
:
logger
.
info
(
"Creating segment %s instance (%s)."
%
(
s
,
curr_dir
))
self
.
conn
.
execute
(
c
=
self
.
conn
.
execute
(
'insert into segments (seg, curr_dir, tag, comment) values (?, ?, ?, ?)'
,(
s
,
curr_dir
,
""
,
docline
))
,(
s
,
curr_dir
,
""
,
docline
))
seg_id
=
c
.
lastrowid
self
.
seg_id_cache
[
s
]
=
seg_id
logger
.
info
(
"Storing connectivity for segment %s."
%
s
)
for
p
in
self
.
pipe
.
_parents
[
s
]:
self
.
conn
.
execute
(
'insert into segment_relations (father_id, child_id) values (?, ?)'
,(
self
.
seg_id_cache
[
p
],
seg_id
))
self
.
conn
.
commit
()
def
_asynchronous_request
(
self
,
sqlrequest
,
args
):
...
...
pipelet/web.py
View file @
d0957430
...
...
@@ -153,7 +153,13 @@ class Web:
list of segid, for the upstream segment instances.
"""
## TO DO : get subpipes somewhere ???
conn
=
sqlite3
.
connect
(
self
.
db_file
,
check_same_thread
=
True
)
with
conn
:
seg
,
currdir
=
conn
.
execute
(
'select father_id from segments where child_id = ?'
,(
segid
,)).
fetchall
()
l
=
conn
.
execute
(
'select str_prod from tasks where seg_id=? and status=?'
,(
segid
,
status
)).
fetchall
()
conn
.
close
()
return
[
int
(
segid
)]
@
cherrypy
.
expose
...
...
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