IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23430


Ignore:
Timestamp:
Mar 19, 2009, 12:01:31 PM (17 years ago)
Author:
bills
Message:

if the input chip run has been magicked set warpSkyfile.magicked to true

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/warp_skycell.pl

    r23295 r23430  
    3636}
    3737
    38 my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps);
     38my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $magicked, $verbose, $no_update, $no_op, $redirect, $save_temps);
    3939GetOptions(
    4040    'warp_id|i=s'         => \$warp_id, # Warp identifier
     
    4747    'threads=s'           => \$threads,   # Number of threads to use for pswarp
    4848    'run-state=s'         => \$run_state,  # 'new' or 'update'
     49    'magicked'            => \$magicked,  # input run has been magicked already?
    4950    'verbose'             => \$verbose,   # Print to stdout
    5051    'no-update'           => \$no_update, # Don't update the database?
     
    246247            $command .= " -tess_id $tess_dir";
    247248            $command .= " -path_base $outroot"; # needed for logfile lookups
     249            $command .= " -magicked" if $magicked;
    248250
    249251            $command .= " -uri $outputImage" if $accept;
  • trunk/ippTasks/warp.pro

    r23230 r23430  
    289289    book getword warpPendingSkyCell $pageName exp_tag -var EXP_TAG
    290290    book getword warpPendingSkyCell $pageName state -var RUN_STATE
     291    book getword warpPendingSkyCell $pageName magicked -var CHIP_MAGICKED
     292    if ("$CHIP_MAGICKED" == "T")
     293        $MAGICKED_ARG = "-magicked"
     294    else
     295        $MAGICKED_ARG = ""
     296    end
     297
    291298
    292299    # set the host and workdir based on the skycell hash
     
    300307    stderr $LOGDIR/warp.skycell.log
    301308
    302     $run = warp_skycell.pl --threads @MAX_THREADS@ --warp_id $WARP_ID --warp_skyfile_id $WARP_SKYFILE_ID --skycell_id $SKYCELL_ID --tess_dir $TESS_DIR --camera $CAMERA --outroot $outroot --redirect-output --run-state $RUN_STATE
     309    $run = warp_skycell.pl --threads @MAX_THREADS@ --warp_id $WARP_ID --warp_skyfile_id $WARP_SKYFILE_ID --skycell_id $SKYCELL_ID --tess_dir $TESS_DIR --camera $CAMERA --outroot $outroot --redirect-output --run-state $RUN_STATE $MAGICKED_ARG
    303310    add_standard_args run
    304311
  • trunk/ippTools/share/Makefile.am

    r23252 r23430  
    172172     warptool_donecleanup.sql \
    173173     warptool_exp.sql \
     174     warptool_finished_run_select.sql \
     175     warptool_finish_run.sql \
    174176     warptool_imfile.sql \
    175177     warptool_pendingcleanuprun.sql \
  • trunk/ippTools/src/warptool.c

    r23418 r23430  
    922922    PS_ASSERT_PTR_NON_NULL(config, false);
    923923
    924     // XXX this SQL has not been broken out to into seperate files as the MYSQL
    925     // < 5 & MYSQL 5 versions need to be kept in sync
    926 
    927 #undef MYSQL5
    928 #if MYSQL5
    929     // XXX at MySQL 4.1.21 (probably all of 4.1.x) chokes and dies on this
    930     // statement as it thinks it is trying to select from the table being
    931     // updated. The 4.1 manual says that nested sub-queries are explicited
    932     // allowed to do this with update statements as a temporary table is
    933     // created so that you are not actually selecting from the table you are
    934     // modifying.
    935     char *query =
    936         "UPDATE warpRun\n"
    937         "   SET warpRun.state = 'stop'\n"
    938         " WHERE\n"
    939         "   warpRun.warp_id =\n"
    940         "   (SELECT DISTINCT\n"
    941         "       warp_id\n"
    942         "   FROM\n"
    943         "       (SELECT DISTINCT\n"
    944         "           warpRun.warp_id,\n"
    945         "           warpSkyCellMap.warp_id as foo,\n"
    946         "           warpSkyfile.warp_id as bar\n"
    947         "       FROM warpRun\n"
    948         "       JOIN warpSkyCellMap\n"
    949         "           USING(warp_id)\n"
    950         "       LEFT JOIN warpSkyfile\n"
    951         "           USING(warp_id, skycell_id, tess_id)\n"
    952         "       WHERE\n"
    953         "           warpRun.state = 'new'\n"
    954         "       GROUP BY\n"
    955         "           warpRun.warp_id\n"
    956         "       HAVING\n"
    957         "       COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n"
    958         "       ) as Foo\n"
    959         "   )\n";
     924    psString query = pxDataGet("warptool_finished_run_select.sql");
     925    if (!query) {
     926        psError(PXTOOLS_ERR_DATA, false, "failed to retrieve SQL statement");
     927        return false;
     928    }
    960929
    961930    if (!p_psDBRunQuery(config->dbh, query)) {
    962931        psError(PS_ERR_UNKNOWN, false, "database error");
    963         return false;
    964     }
    965 #else // if MYSQL5
    966 {
    967     char *query =
    968         "CREATE TEMPORARY TABLE finished\n"
    969         " (warp_id INT, PRIMARY KEY(warp_id)) ENGINE=MEMORY\n";
    970 
    971     if (!p_psDBRunQuery(config->dbh, query)) {
    972         psError(PS_ERR_UNKNOWN, false, "database error");
    973         return false;
    974     }
    975 }
    976 
    977 {
    978     char *query =
    979         "INSERT INTO finished\n"
    980         " SELECT\n"
    981         "   warp_id\n"
    982         " FROM\n"
    983         "   (SELECT DISTINCT\n"
    984         "       warpRun.warp_id,\n"
    985         "       warpSkyCellMap.warp_id as foo,\n"
    986         "       warpSkyfile.warp_id as bar\n"
    987         "   FROM warpRun\n"
    988         "   JOIN warpSkyCellMap\n"
    989         "       USING(warp_id)\n"
    990         "   LEFT JOIN warpSkyfile\n"
    991         "       USING(warp_id, skycell_id)\n"
    992         "   WHERE\n"
    993         "       warpRun.state = 'new'\n"
    994         "   GROUP BY\n"
    995         "       warpRun.warp_id\n"
    996         "   HAVING\n"
    997         "       COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n"
    998         " ) as Foo \n";
    999 
    1000     if (!p_psDBRunQuery(config->dbh, query)) {
    1001         psError(PS_ERR_UNKNOWN, false, "database error");
    1002         return false;
    1003     }
    1004 }
    1005 
    1006 {
    1007     char *query =
    1008         "UPDATE warpRun\n"
    1009         "   SET warpRun.state = 'full'\n"
    1010         " WHERE\n"
    1011         "   warpRun.warp_id =\n"
    1012         "   (SELECT DISTINCT\n"
    1013         "       warp_id\n"
    1014         "   FROM finished\n"
    1015         "   )\n";
    1016 
    1017     if (!p_psDBRunQuery(config->dbh, query)) {
    1018         psError(PS_ERR_UNKNOWN, false, "database error");
    1019         return false;
    1020     }
    1021 }
    1022 #endif // if MYSQL5
     932        psFree(query);
     933        return false;
     934    }
     935    psFree(query);
     936
     937    psArray *output = p_psDBFetchResult(config->dbh);
     938    if (!output) {
     939        psError(PS_ERR_UNKNOWN, false, "database error");
     940        return false;
     941    }
     942    if (!psArrayLength(output)) {
     943        psTrace("warptool", PS_LOG_INFO, "no rows found");
     944        psFree(output);
     945        return true;
     946    }
     947
     948    query = pxDataGet("warptool_finish_run.sql");
     949    for (long i = 0; i < psArrayLength(output); i++) {
     950        psMetadata *row = output->data[i];
     951
     952        bool status;
     953        psS64 warp_id = psMetadataLookupS64(&status, row, "warp_id");
     954        if (!status) {
     955            psError(PS_ERR_UNKNOWN, false, "failed to look up value for warp_id");
     956            psFree(output);
     957            psFree(query);
     958            return false;
     959        }
     960        psS32 magicked = psMetadataLookupS64(&status, row, "magicked");
     961        if (!status) {
     962            psError(PS_ERR_UNKNOWN, false, "failed to look up value for magicked");
     963            psFree(output);
     964            psFree(query);
     965            return false;
     966        }
     967        if (!p_psDBRunQueryF(config->dbh, query, magicked, warp_id)) {
     968            psError(PS_ERR_UNKNOWN, false, "database error");
     969            psFree(output);
     970            psFree(query);
     971            return false;
     972        }
     973
     974        psS64 numUpdated = psDBAffectedRows(config->dbh);
     975
     976        if (numUpdated != 1) {
     977            psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
     978            psFree(query);
     979            psFree(output);
     980            return false;
     981        }
     982    }
     983    psFree(output);
     984    psFree(query);
    1023985
    1024986    return true;
Note: See TracChangeset for help on using the changeset viewer.