Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

track renderjob frames in a table

  • Loading branch information...
commit ebd6721ddc8016b0815691abbd2252160933090c 1 parent defa413
@orlandov authored
View
12 db/legion.sql
@@ -9,7 +9,17 @@ CREATE TABLE source (
CREATE TABLE renderjob (
renderjob_id SERIAL PRIMARY KEY,
- source_id INT NOT NULL REFERENCES source ON DELETE RESTRICT
+ source_id INT NOT NULL REFERENCES source ON DELETE RESTRICT,
+ status VARCHAR(255) NOT NULL
+);
+
+CREATE TABLE frame (
+ frame_id SERIAL PRIMARY KEY,
+ frame_number INT NOT NULL,
+ renderjob_id INT NOT NULL REFERENCES renderjob ON DELETE CASCADE,
+ sha1 VARCHAR(255),
+ render_elapsed FLOAT,
+ status VARCHAR(255)
);
COMMIT;
View
1  resetdb → fresh-dev-env
@@ -17,3 +17,4 @@ system("psql '$dbname' -f db/legion.sql");
system("cd ../Legion-JobQueue/; psql '$schwartz' -f db/theschwartz.sql");
system("./script/legion_web_create.pl model DB DBIC::Schema Legion::Schema create=static dbi:Pg:dbname=$dbname");
system("rm storage_dir/*");
+#system("./script/legion_web_server.pl -r -d &");
View
4 lib/Legion/Schema.pm
@@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema';
__PACKAGE__->load_namespaces;
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-23 22:25:04
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vgST1t+nj3IZnDpez5r6aQ
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-29 21:26:00
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E0MmSTftb+Z611FmBO+N7g
# You can replace this text with custom content, and it will be preserved on regeneration
View
58 lib/Legion/Schema/Result/Frame.pm
@@ -0,0 +1,58 @@
+package Legion::Schema::Result::Frame;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("InflateColumn::DateTime", "Core");
+__PACKAGE__->table("frame");
+__PACKAGE__->add_columns(
+ "frame_id",
+ {
+ data_type => "integer",
+ default_value => "nextval('frame_frame_id_seq'::regclass)",
+ is_nullable => 0,
+ size => 4,
+ },
+ "frame_number",
+ { data_type => "integer", default_value => undef, is_nullable => 0, size => 4 },
+ "renderjob_id",
+ { data_type => "integer", default_value => undef, is_nullable => 0, size => 4 },
+ "sha1",
+ {
+ data_type => "character varying",
+ default_value => undef,
+ is_nullable => 1,
+ size => 255,
+ },
+ "render_elapsed",
+ {
+ data_type => "double precision",
+ default_value => undef,
+ is_nullable => 1,
+ size => 8,
+ },
+ "status",
+ {
+ data_type => "character varying",
+ default_value => undef,
+ is_nullable => 1,
+ size => 255,
+ },
+);
+__PACKAGE__->set_primary_key("frame_id");
+__PACKAGE__->add_unique_constraint("frame_pkey", ["frame_id"]);
+__PACKAGE__->belongs_to(
+ "renderjob_id",
+ "Legion::Schema::Result::Renderjob",
+ { renderjob_id => "renderjob_id" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-29 21:26:00
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yhutH438cEi5TfAC0vBluQ
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
View
16 lib/Legion/Schema/Result/Renderjob.pm
@@ -17,9 +17,21 @@ __PACKAGE__->add_columns(
},
"source_id",
{ data_type => "integer", default_value => undef, is_nullable => 0, size => 4 },
+ "status",
+ {
+ data_type => "character varying",
+ default_value => undef,
+ is_nullable => 0,
+ size => 255,
+ },
);
__PACKAGE__->set_primary_key("renderjob_id");
__PACKAGE__->add_unique_constraint("renderjob_pkey", ["renderjob_id"]);
+__PACKAGE__->has_many(
+ "frames",
+ "Legion::Schema::Result::Frame",
+ { "foreign.renderjob_id" => "self.renderjob_id" },
+);
__PACKAGE__->belongs_to(
"source_id",
"Legion::Schema::Result::Source",
@@ -27,8 +39,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-23 22:25:04
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wpGFvLqQbkCWhmXuK7XF2g
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-29 21:26:00
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lEvFZu+A7ZzdacfEPouxfw
# You can replace this text with custom content, and it will be preserved on regeneration
View
4 lib/Legion/Schema/Result/Source.pm
@@ -41,8 +41,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-23 22:25:04
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fKXNzprUOLbL4prNj92+Pw
+# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-07-29 21:26:00
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ouQPH0Hvw3DfjDMT+L0FFA
# You can replace this text with custom content, and it will be preserved on regeneration
View
46 lib/Legion/Web/Controller/Root.pm
@@ -52,9 +52,9 @@ sub render : Local Args(0) {
my $source = $sources_rs->find($source_id);
- $jobs_rs->create({ source_id => $source_id });
+ $jobs_rs->create({ source_id => $source_id, status => 'idle' });
- $c->flash->{message} = "Render job created for " . $source->filename;
+ $c->flash->{success} = "Render job created for " . $source->filename;
$c->res->redirect($c->uri_for('/'));
}
@@ -66,23 +66,42 @@ sub start_renderjob : Local Args(0) {
my $renderjob_id = $c->req->params->{renderjob_id}
or die "No job specified";
- my $sources_rs = $c->model('DB::Source');
- my $source_id = $c->req->params->{source_id};
- my $source = $sources_rs->find($source_id);
-
# TODO validation
my $renderjobs_rs = $c->model('DB::Renderjob');
my $renderjob = $renderjobs_rs->find($renderjob_id);
-
+ $renderjob->status('active');
+ $renderjob->update;
+
+ my $frame_rs = $c->model('DB::Frame');
+ $frame_rs->populate(
+ [
+ [ qw/ frame_number renderjob_id status / ],
+ map { [ $_, $renderjob_id, 'incomplete' ] } (1 .. 250)
+ ]
+ );
my $schwartz = TheSchwartz::Simple->new([$dbh]);
$schwartz->insert(
'Legion::Worker::Renderer',
{
renderjob_id => $renderjob_id,
- frame_first => 1,
- frame_last => 250
+ frame_number => 1,
}
);
+
+
+ $c->flash->{success} = 'Started job';
+ $c->res->redirect($c->uri_for('/'));
+}
+
+sub view_job_files : Local Args(0) {
+ my ($self, $c) = @_;
+
+ my $renderjob_id = $c->req->params->{id};
+ my $renderjobs_rs = $c->model('DB::Renderjob');
+ my $renderjob = $renderjobs_rs->find($renderjob_id);
+
+ $c->stash->{frames} = [ $renderjob->search_related('frames')->all ];
+ $c->stash->{template} = 'view_job_files.tt2';
}
sub root_redir {
@@ -118,7 +137,7 @@ sub delete_source : Local Args(0) {
unlink $storage_filename
or die "Couldn't delete source $filename";
- $c->flash->{message} = "Source $filename successfully deleted";
+ $c->flash->{success} = "Source $filename successfully deleted";
$c->res->redirect($c->uri_for('/'));
}
@@ -142,10 +161,11 @@ sub files : Local Args(0) {
$file->copy_to("$storage_dir/$digest");
my $schema = $c->model('DB::Source');
- $schema->create(
- { filename => $filename, sha1 => $digest, filesize => $file->size });
+ $schema->create({ filename => $filename, sha1 => $digest,
+ filesize => $file->size });
+
- $c->stash->{message} = "$filename successfully uploaded";
+ $c->stash->{success} = "$filename successfully uploaded";
$c->res->redirect($c->uri_for('/'));
}
View
7 root/lib/site/html
@@ -13,8 +13,11 @@
<link rel="stylesheet" href="/static/css/blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
<!-- jQuery -->
- <link type="text/css" href="/static/jquery-ui/css/smoothness/jquery-ui-1.7.2.custom.css" rel="Stylesheet" />
- <script type="text/javascript" src="/static/jquery-ui/js/jquery-1.3.2.min.js"></script>
+ <!-- <link type="text/css"
+ href="/static/jquery-ui/css/smoothness/jquery-ui-1.7.2.custom.css"
+ rel="Stylesheet" />
+ <script type="text/javascript"
+ src="/static/jquery-ui/js/jquery-1.3.2.min.js"></script> -->
<script type="text/javascript"
src="/static/jquery-ui/js/jquery-ui-1.7.2.custom.min.js"></script>
<style>
View
83 root/src/submit.tt2
@@ -5,8 +5,14 @@
<hr/>
-[% IF message %]
-<div class="ui-state-highlight ui-corner-all">[% message %]</div>
+[% IF error %]
+<div class="error">[% error %]</div>
+[% END %]
+[% IF notice %]
+<div class="notice">[% notice %]</div>
+[% END %]
+[% IF success %]
+<div class="success">[% success %]</div>
[% END %]
<h2>Upload Source</h2>
@@ -24,44 +30,55 @@
<h2>Source Files</h2>
<div id="sources">
- <table>
- [% FOREACH source=sources %]
- <tr><td>[% source.filename %]</td>
- <td>[% source.sha1 or '-' %]</td>
- <td>
- <a href="[% c.uri_for('render', source_id=source.source_id) %]">Render</a>
- | <a href="[% c.uri_for('delete_source', source_id=source.source_id) %]">Delete</a>
- </td>
- </tr>
- <!--
- <ul class="ui-widget ui-helper-clearfix">
- <li style="width: 50%; display: inline"></li>
- <li style="display: inline">[% file.sha1 or '&nbsp;' %]</li>
- <li style="display: inline=
- <a href="#">Render</a>
- <a href="#">Delete</a>
- </li>
- </ul> -->
+ [% IF sources.size %]
+ <table>
+ [% FOREACH source=sources %]
+ <tr><td>[% source.filename %]</td>
+ <td>[% source.sha1 or '-' %]</td>
+ <td>
+ <a href="[% c.uri_for('render', source_id=source.source_id) %]">Render</a>
+ | <a href="[% c.uri_for('delete_source', source_id=source.source_id) %]">Delete</a>
+ </td>
+ </tr>
+ <!--
+ <ul class="ui-widget ui-helper-clearfix">
+ <li style="width: 50%; display: inline"></li>
+ <li style="display: inline">[% file.sha1 or '&nbsp;' %]</li>
+ <li style="display: inline=
+ <a href="#">Render</a>
+ <a href="#">Delete</a>
+ </li>
+ </ul> -->
+ [% END %]
+ </table>
+ [% ELSE %]
+ <div class="notice">
+ You don't currently have any source files.
+ </div>
[% END %]
- </table>
</div>
<hr/>
<h2>Render Jobs</h2>
<div id="jobs">
- [% FOR job=jobs %]
- <div class="job">
- job_id = [% job.renderjob_id %]
- <!-- <code><pre>[% Dumper.dump_html(job) %]</pre></code> -->
- source = [% job.source_id.filename %]
- <a href="[% c.uri_for('delete_job', renderjob_id=job.renderjob_id) %]">Delete</a>
- </div>
+ [% IF jobs.size %]
+ [% FOR job=jobs %]
+ <div class="job">
+ job_id = [% job.renderjob_id %]
+ status = [% job.status %]
+ source = [% job.source_id.filename %]
+ [% job.frames.size %] frames
+ <a href="[% c.uri_for('view_job_files', id=job.renderjob_id) %]">View files</a>
+ <a href="[% c.uri_for('start_renderjob', renderjob_id=job.renderjob_id) %]">Start</a> |
+ <a href="[% c.uri_for('delete_job', renderjob_id=job.renderjob_id) %]">Delete</a>
+ </div>
+ [% END %]
+ [% ELSE %]
+ <div class="notice">
+ You don't currently have any render jobs.
+ </div>
[% END %]
</div>
-<script>
- $(function() {
-// $("#tabs").tabs();
- });
-</script>
+<hr />
View
26 root/src/view_job_files.tt2
@@ -0,0 +1,26 @@
+[% USE Dumper %]
+
+<pre>[%# Dumper.dump_html(frames) %]</pre>
+
+<table>
+ <thead>
+ <th>Frame number</th>
+ <th>Status</th>
+ <th>SHA1</th>
+ <th>Elapsed Time</th>
+ <th>jo
+ </thead>
+<tbody>
+[% FOR frame=frames %]
+ <tr>
+ <td>[% frame.frame_number %]</td>
+ <td>[% frame.status %]</td>
+ <td>[% frame.sha1 OR '-' %]</td>
+ <td>[% frama.elapsed OR '-' %]
+ <td>[% frame.renderjob_id.renderjob_id %]</td>
+ </tr>
+[% END %]
+ <tr>
+ <td colspan="3">[% frames.size %] frame(s)</td>
+ </tr>
+</table>
Please sign in to comment.
Something went wrong with that request. Please try again.