isa => 'Str',
);
-has pars_pk => (
- is => 'rw',
- isa => 'Int',
- );
-
=head1 NAME
stemmaweb::Controller::Stemweb - Client listener for Stemweb results
} # otherwise we have no available algorithms.
## Temporary HACK: run Pars too
if( $self->_has_pars ) {
- # Use the highest passed primary key + 1
- my $parspk = max( map { $_->{pk} }
- grep { $_->{model} eq 'algorithms.algorithm' } @$parameters ) + 1;
+ # Use 100 as the special pars key
# Add Pars as an algorithm
- $self->pars_pk( $parspk );
push( @$parameters, {
- pk => $parspk,
+ pk => 100,
model => 'algorithms.algorithm',
fields => {
args => [],
}
$c->stash->{'result'} = { status => 'notfound' };
}
- } elsif( $answer->{status} == -1 ) {
+ } elsif( $answer->{status} == 1 || $answer->{status} == -1 ) {
+ # 1 means running, -1 means waiting to run. Either way, 'not ready'.
$c->stash->{'result'} = { 'status' => 'running' };
} else {
- return _json_error( $c, 500,
- "Stemweb failure not handled: " . $answer->{result} );
+ # Failure. Clear the job ID so that the user can try again.
+ $tradition->_clear_stemweb_jobid;
+ $m->save( $tradition );
+ $c->stash->{'result'} = { 'status' => 'failed', 'message' => $answer->{result} };
}
$c->forward('View::JSON');
}
my $algorithm = delete $reqparams->{algorithm};
my $mergetypes = delete $reqparams->{merge_reltypes};
- if( $self->_has_pars && $algorithm == $self->pars_pk ) {
+ if( $self->_has_pars && $algorithm == 100 ) {
my $start_time = scalar( gmtime( time() ) );
$t->set_stemweb_jobid( 'local' );
my $cdata = character_input( $t, { collapse => $mergetypes } );
} else {
# Form the request for Stemweb.
my $return_uri = URI->new( $c->uri_for( '/stemweb/result' ) );
- my $tsv_options = { noac => 1 };
+ my $tsv_options = { noac => 1, ascii => 1 };
if( $mergetypes && @$mergetypes ) {
$tsv_options->{mergetypes} = $mergetypes;
}
# Call to the appropriate URL with the request parameters.
my $ua = LWP::UserAgent->new();
- $c->log->debug( 'Sending request to Stemweb: ' . to_json( $stemweb_request ) );
+ # $c->log->debug( 'Sending request to Stemweb: ' . to_json( $stemweb_request ) );
my $resp = $ua->post( $self->stemweb_url . "/algorithms/process/$algorithm/",
'Content-Type' => 'application/json; charset=utf-8',
'Content' => encode_json( $stemweb_request ) );