IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27795


Ignore:
Timestamp:
Apr 28, 2010, 2:18:01 PM (16 years ago)
Author:
bills
Message:

first crack at queuing automatic updates for diffSkyfiles. Various bug fixes found in testing

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r27783 r27795  
    455455    my $inverse = $option_mask & $PSTAMP_SELECT_INVERSE;
    456456
    457     my $command = "$difftool -diffskyfile -dbname $imagedb";
     457    my $command = "$difftool -dbname $imagedb";
    458458   
    459459    if ($byid) {
    460         $command .= " -diff_id $id";
     460        $command .= " -listrun -diff_id $id";
    461461    } else {
    462         $command .= " -diff_skyfile_id $id";
     462        $command .= " -diffskyfile -diff_skyfile_id $id";
    463463    }
    464464    $command .= " -skycell_id $skycell_id" if $skycell_id;
    465465
    466     my $images = runToolAndParse($command, $verbose);
    467 
    468     my $n = @$images;
     466    my $output = runToolAndParse($command, $verbose);
     467
     468    my $n = @$output;
    469469    if (!$byid && ($n > 1)) {
    470470        die ("difftool returned an unexpected number of diffskyfiles: $n");
    471471    } elsif ($n == 0) {
    472472        return undef;
     473    }
     474
     475    my $images;
     476    if ($byid) {
     477        $images = selectComponents($ipprc, $imagedb, 'byid', 'diff', $rowList, $output, $verbose);
     478    } else {
     479        $images = $output;
    473480    }
    474481
  • trunk/ippTasks/pstamp.pro

    r27751 r27795  
    524524
    525525    periods     -poll $LOADPOLL
    526     # XXX: create a macro for this
    527     periods     -exec 30
     526    # XXX: create a macro for this time
     527    periods     -exec 10
    528528#    periods     -exec $LOADEXEC
    529     periods     -timeout 30
     529    periods     -timeout 300
    530530    npending    1
    531531
  • trunk/ippTools/share/Makefile.am

    r27777 r27795  
    114114     difftool_pendingcleanupskyfile.sql \
    115115     difftool_revertdiffskyfile_delete.sql \
    116      difftool_revertdiffskyfile_update.sql \
     116     difftool_revertdiffskyfile_updated.sql \
     117     difftool_setskyfiletoupdate.sql \
    117118     difftool_skyfile.sql \
    118119     difftool_todiffskyfile.sql \
     
    223224     pstamptool_completedreq.sql \
    224225     pstamptool_datastore.sql \
     226     pstamptool_getdependent.sql \
    225227     pstamptool_listjob.sql \
    226228     pstamptool_pendingdependent.sql \
  • trunk/ippTools/share/pstamptool_pendingdependent.sql

    r27740 r27795  
    44JOIN pstampRequest USING(req_id)
    55WHERE pstampDependent.state = 'new'
     6    AND pstampDependent.fault = 0
    67    AND pstampJob.state = 'run'
     8    AND pstampRequest.state = 'run'
  • trunk/ippTools/share/pstamptool_revertdependent.sql

    r27740 r27795  
    33    JOIN pstampRequest USING(req_id)
    44SET pstampDependent.fault = 0
     5WHERE pstampDependent.state = 'new'
  • trunk/ippTools/src/pstamptool.c

    r27740 r27795  
    530530
    531531    PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "==");
    532     PXOPT_COPY_S64(config->args, where, "-fault", "req_id", "==");
     532    PXOPT_COPY_S64(config->args, where, "-fault", "fault", "==");
    533533    PXOPT_COPY_STR(config->args, where, "-state", "pstampRequest.state", "==");
    534534    pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE");
     
    967967    PXOPT_LOOKUP_STR(component,   config->args, "-component",  true, false);
    968968    PXOPT_LOOKUP_STR(imagedb,     config->args, "-imagedb",  true, false);
    969     PXOPT_LOOKUP_STR(rlabel,      config->args, "-rlabel",  false, false);
     969    PXOPT_LOOKUP_STR(rlabel,      config->args, "-rlabel",  true, false);
    970970    PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false);
    971971    PXOPT_LOOKUP_BOOL(no_create,  config->args, "-no_create", false);
     
    983983    }
    984984
    985     psString query = pxDataGet("pstamptool_pendingdependent.sql");
     985    psString query = pxDataGet("pstamptool_getdependent.sql");
    986986    if (!query) {
    987987        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     
    11861186
    11871187    psMetadata *where = psMetadataAlloc();
    1188     PXOPT_COPY_S64(config->args, where, "-fault", "req_id", "==");
     1188    PXOPT_COPY_S64(config->args, where, "-fault", "pstampDependent.fault", "==");
    11891189    PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "==");
    11901190    pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "==");
     
    12011201    }
    12021202
    1203     psString whereClause = psDBGenerateWhereSQL(where, NULL);
    1204     psStringAppend(&query, " %s", whereClause);
     1203    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1204    psStringAppend(&query, " AND %s", whereClause);
    12051205    psFree(whereClause);
    12061206    psFree(where);
  • trunk/ippTools/src/pstamptoolConfig.c

    r27740 r27795  
    177177    psMetadata *revertdependentArgs = psMetadataAlloc();
    178178    psMetadataAddS64(revertdependentArgs, PS_LIST_TAIL, "-dep_id", 0, "define id for dependent", 0);
    179     psMetadataAddS16(revertdependentArgs, PS_LIST_TAIL, "-fault",  0,   "new value for fault", 0);
     179    psMetadataAddStr(revertdependentArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK,   "define label for dependent ", NULL);
     180    psMetadataAddS16(revertdependentArgs, PS_LIST_TAIL, "-fault",  0,   "define fault", 0);
    180181
    181182    // -pendingdependent
  • trunk/pstamp/scripts/pstamp_checkdependent.pl

    r27751 r27795  
    270270
    271271        if ($good_to_go) {
     272            # the reason we defer setting the warp to update is so that we can handle error conditions at previous
     273            # stages more easily.
    272274            my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}";
    273275            $command .= " -set_label $rlabel" if $rlabel;
     
    341343        my $skycell_id = $skycell->{skycell_id};
    342344
    343         # put this in a module somewhere
     345        # XXX: put this in a module somewhere
    344346        my $IPP_DIFF_MODE_WARP_WARP   = 1;
    345347        my $IPP_DIFF_MODE_WARP_STACK  = 2;
     
    347349        my $IPP_DIFF_MODE_STACK_STACK = 4;
    348350        if ($diff_mode == $IPP_DIFF_MODE_WARP_STACK ) {
    349             # check the state of the stack
     351            # check the state of the template stack
    350352            my $command = "$stacktool -sumkskyfile -stack_id $skycell->{stack2}";
    351353            my $stack = runToolAndParseExpectOne($command, $verbose);
     
    361363            # now check the warp
    362364            $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id";
    363             my $warp = runToolAndExpectOne($command, $verbose);
    364             my_die("failed to find warpSkyfile for warpRun $skycell->{warp_id} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR)
    365                 if !$warp;
    366         }
    367 
    368         my $good_to_go = 1;
    369         my @chipsToUpdate;
    370         my $chip_id;
    371         my $warp_id;
    372         my $data ;  #XXXX
    373         foreach my $chip (@$data) {
    374             $chip_id = $chip->{chip_id};
    375             if (($chip->{data_state} ne 'full') or ($need_magic and ($chip->{magicked} <= 0))) {
    376                 $good_to_go = 0;
    377                 push @chipsToUpdate, $chip;
    378             } else {
    379                 # this chip is good to go
    380             }
    381         }
    382 
    383         if ($good_to_go) {
    384             my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}";
    385             $command .= " -set_label $rlabel" if $rlabel;
    386 
    387             if (!$no_update) {
    388                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    389                             run(command => $command, verbose => $verbose);
    390                 unless ($success) {
    391                     my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
     365            my $warp = runToolAndParseExpectOne($command, $verbose);
     366            my_die("failed to find warpSkyfile for warpRun $skycell->{warp_id} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp;
     367
     368            if ($warp->{data_state} ne 'full') {
     369                return queue_update_warp($warp, 0, $rlabel, $need_magic);
     370            }
     371            # warps are ready fall through and queue the diff update
     372        } elsif ($diff_mode eq $IPP_DIFF_MODE_WARP_WARP) {
     373            my $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id";
     374            my $warp1 = runToolAndParseExpectOne($command, $verbose);
     375            my_die("failed to find warpSkyfile for warpRun $skycell->{warp_id} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp1;
     376
     377            if ($warp1->{data_state} ne 'full') {
     378                my $status = queue_update_warp($warp1, 0, $rlabel, $need_magic);
     379                if ($status) {
     380                    return $status;
    392381                }
    393             } else {
    394                 print "skipping $command\n";
    395             }
    396         } elsif (scalar @chipsToUpdate > 0) {
    397             return queue_update_chip($chip_id, 0, \@chipsToUpdate, $rlabel, $need_magic);
    398         }
    399     } else {
    400         my $warpRun = $metadata;
    401         my $warp_id = $warpRun->{warp_id};
    402         my $command = "$chiptool -listrun -chip_id $warpRun->{chip_id}";
    403         my $data = runToolAndParse($command, $verbose);
    404         my_die("failed to find chipRun $warpRun->{chip_id} for warpRun $warp_id", $PS_EXIT_UNKNOWN_ERROR)
    405             if !$data or scalar @$data != 1;
    406 
    407         my $chipRun = $data->[0];
    408 
    409         my $chipRunState = $chipRun->{state};
    410         if (($chipRunState =~ /purge/) or ($chipRunState =~ /scrub/)) {
    411             print STDERR "warpRun $warp_id depends on chipRun $chipRun->{chip_id} which is in state $chipRunState\n";
    412             faultJobs('stop', 'warp', $warp_id, $PSTAMP_GONE);
    413             return 0;
    414         }
    415         my $warpRunState = $warpRun->{state};
    416         if (($chipRunState eq 'full') and (! $need_magic or ($chipRun->{magicked} > 0)) and ($warpRunState eq 'cleaned')) {
    417             # The inputs and outputs are ready. Queue the warpRun for update.
    418 
    419             # providing no -skycell_id arguments changes all skyfiles with data_state = 'cleaned' to 'update'
    420             my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id";
    421             $command .= " -set_label $rlabel" if $rlabel;
    422 
    423             if (!$no_update) {
    424                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    425                             run(command => $command, verbose => $verbose);
    426                 unless ($success) {
    427                     my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
    428                 }
    429             } else {
    430                 print "skipping $command\n";
    431             }
    432         } elsif ($chipRunState eq 'cleaned' or
    433             (($chipRun->{state} eq 'full') and ($need_magic and ($chipRun->{magicked} < 0) and ($chipRun->{dsRun_state} ne 'new')))) {
    434             my $data = [$chipRun];
    435             return queue_update_chip($chipRun->{chip_id}, 1, $data, $rlabel, $need_magic);
    436         }
    437     }
    438 
     382            }
     383            $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id";
     384            my $warp2 = runToolAndParseExpectOne($command, $verbose);
     385            my_die("failed to find warpSkyfile for warpRun $skycell->{warp_id} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp2;
     386
     387            if ($warp2->{data_state} ne 'full') {
     388                return queue_update_warp($warp2, 0, $rlabel, $need_magic);
     389            }
     390            # fall through to queue the diff update
     391        } else {
     392            # XXX: check stack stack
     393            print STDERR "unexpected diff_mode found: $diff_mode\n";
     394            return $PS_EXIT_PROG_ERROR;
     395        }
     396
     397        my $command = "$difftool -setskyfiletoupdate -diff_id $diff_id -skycell_id $skycell_id";
     398        $command .= " -set_label $rlabel" if $rlabel;
     399
     400        if (!$no_update) {
     401            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     402                        run(command => $command, verbose => $verbose);
     403            unless ($success) {
     404                my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR);
     405            }
     406        } else {
     407            print "skipping $command\n";
     408        }
     409    } else {
     410        # XXX todo whole_run
     411        return $PS_EXIT_PROG_ERROR;
     412    }
    439413    # return value may be the return status of script so zero is good
    440414    return 0;
     
    593567    carp $msg;
    594568
    595     my $command = "$pstamptool -updatedepedent -fault $fault -dep_id $dep_id";
     569    my $command = "$pstamptool -updatedependent -fault $fault -dep_id $dep_id";
    596570    $command .= " -dbname $dbname" if $dbname;
    597571    $command .= " -dbserver $dbserver" if $dbserver;
     
    600574                    run(command => $command, verbose => $verbose);
    601575        unless ($success) {
    602             my_die("failed to set pstampDependent.fault for dep_id: $dep_id",
    603                 $PS_EXIT_UNKNOWN_ERROR);
     576            carp "$cmd failed";
    604577        }
    605578    } else {
  • trunk/pstamp/scripts/pstampparse.pl

    r27783 r27795  
    536536    # XXX: this code is repeated in queueGetImageJobs we should encapsulate it in a subroutine and share it
    537537    if ($stage ne 'raw') {
    538         # not ready to handle diff update yet. May never support stack
    539         my $allow_wait_for_update = (($stage ne 'stack') and ($stage ne 'diff'));
     538        # updates for stack stage not supported yet
     539        my $allow_wait_for_update = ($stage ne 'stack');
    540540        my $run_state = $image->{state};
    541541        my $data_state = $image->{data_state};
     
    548548            $newState = 'stop';
    549549            $fault = $PSTAMP_GONE;
    550         } elsif ($allow_wait_for_update and
    551                 (($data_state ne 'full') or ($need_magic and ($image->{magicked} < 0)))) {
     550        } elsif (($data_state ne 'full') or ($need_magic and ($image->{magicked} < 0))) {
    552551            if ($stage eq 'chip') {
    553552                my $burntool_state = $image->{burntool_state};
     
    556555                    $fault = $PSTAMP_NOT_AVAILABLE;
    557556                }
     557            }
     558            if (!$allow_wait_for_update) {
     559                print STDERR "wait for update not supported for stage $stage yet\n";
     560                $newState = 'stop';
     561                $fault = $PSTAMP_NOT_AVAILABLE;
    558562            }
    559563            if (!$fault) {
Note: See TracChangeset for help on using the changeset viewer.