IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29561 for trunk/ippScripts


Ignore:
Timestamp:
Oct 26, 2010, 8:39:32 AM (16 years ago)
Author:
bills
Message:

Change the destreak cleanup to preserve the rows in the magicDSFile table

Location:
trunk/ippScripts/scripts
Files:
3 edited

Legend:

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

    r29495 r29561  
    4242# Parse the command-line arguments
    4343my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction);
    44 my ($streaks_path_base, $inv_streaks_path_base);
     44my ($streaks_path_base, $inv_streaks_path_base, $run_state);
    4545my ($outroot, $recoveryroot, $magicked);
    4646my ($replace, $release);
     
    5050           'magic_ds_id=s'  => \$magic_ds_id,# Magic destreak run identifier
    5151           'camera=s'       => \$camera,     # camera for evaluating file rules
     52           'run-state=s'    => \$run_state,   # state of run (new or update)
    5253           'streaks_path_base=s'      => \$streaks_path_base,    # path_base for streaks data
    5354           'inv_streaks_path_base=s'  => \$inv_streaks_path_base, #path_base for streaks from inverse diff
     
    7778
    7879pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    79 pod2usage( -msg => "Required options: --magic_ds_id --camera --streaks --stage --stage_id --component --uri --path_base --outroot --magicked",
     80pod2usage( -msg => "Required options: --magic_ds_id --camera --run_state --streaks --stage --stage_id --component --uri --path_base --outroot --magicked",
    8081           -exitval => 3) unless
    8182    defined $magic_ds_id and
    8283    defined $camera and
     84    defined $run_state and
    8385    defined $streaks and
    8486    defined $streaks_path_base and
     
    113115    &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    114116}
     117
     118&my_die("Invalid value for run-state: $run_state", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
     119    unless ($run_state eq 'new') or ($run_state eq 'update');
     120
    115121$inv_streaks_path_base = undef if defined($inv_streaks_path_base) and ($inv_streaks_path_base eq "NULL");
    116122$inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL");
     
    479485# Input result into database
    480486{
    481     my $command = "$magicdstool -adddestreakedfile";
     487    my $command = "$magicdstool";
    482488    $command   .= " -magic_ds_id $magic_ds_id";
    483489    $command   .= " -component $component";
    484490    $command   .= " -setmagicked" if $replace;
    485     $command   .= " -backup_path_base $backup_path_base" if $backup_path_base;
    486     $command   .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;
    487     $command   .= " $statsFlags" if $statsFlags;
     491    if ($run_state eq 'new') {
     492        $command .= " -adddestreakedfile";
     493        $command .= " -backup_path_base $backup_path_base" if $backup_path_base;
     494        $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;
     495        $command .= " $statsFlags" if $statsFlags;
     496    } else {
     497        $command .= " -tofullfile";
     498    }
    488499    $command   .= " -dbname $dbname" if defined $dbname;
    489500
     
    581592    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
    582593
    583     my $command = "$magicdstool -adddestreakedfile";
     594    my $command = "$magicdstool";
     595   
     596    if ($run_state eq 'new') {
     597        $command .= " -adddestreakedfile";
     598    } else {
     599        $command .= " -updatedestreakedfile";
     600    }
    584601    $command   .= " -magic_ds_id $magic_ds_id";
    585602    $command   .= " -component $component";
  • trunk/ippScripts/scripts/magic_destreak_cleanup.pl

    r29097 r29561  
    8989$q1 .= " WHERE magic_ds_id = $magic_ds_id";
    9090
    91 my $q2 = "SELECT * from magicDSFile where magic_ds_id = $magic_ds_id";
     91my $q2 = "SELECT * from magicDSFile WHERE (data_state = 'full' OR data_state = 'update') AND magic_ds_id = $magic_ds_id";
    9292
    9393my $stmt1 = $dbh->prepare($q1);
     
    245245            delete_files($rimage, $rmask, $rweight, $rsources, undef, $bimage, $bmask, $bweight, $bsources);
    246246        }
    247 }
    248 
    249 $dbh = DBI->connect($dsn, $dbuser, $dbpassword) or die "Cannot connect to mysql server\n";
    250 
    251 if (!$no_update and ($num_components > 0)) {
    252     my $result = $dbh->do("DELETE FROM magicDSFile WHERE magic_ds_id = ?", undef, $magic_ds_id);
    253     # my $result = $stmt3->do($magic_ds_id);
    254     my_die("attempt to delete magicDSFiles failed", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR) if $result eq "0E0";
    255 }
    256 
    257 if (!$no_update) {
    258     my $result = $dbh->do("UPDATE magicDSRun SET state = 'cleaned' WHERE magic_ds_id = ?", undef, $magic_ds_id);
    259     my_die("attempt to update magicDSRun.state failed", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR) if $result eq "0E0";
    260 } else {
    261     print STDERR "skipping update of magicDSRun\n";
    262 }
    263 
     247        my $command = "$magicdstool -tocleanedfile -magic_ds_id $magic_ds_id -component $component";
     248        $command   .= " -dbname $dbname" if defined $dbname;
     249
     250        unless ($no_update) {
     251            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     252                run(command => $command, verbose => $verbose);
     253            unless ($success) {
     254                carp("failed to update database for $magic_ds_id");
     255            }
     256        } else {
     257            print "Skipping command: $command\n";
     258        }
     259}
    264260
    265261### Pau.
     
    292288    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
    293289
    294     my $command = "$magicdstool -updaterun -set_state failed_cleanup";
     290    my $command = "$magicdstool -updaterun -set_state error_cleaned";
    295291    $command   .= " -magic_ds_id $magic_ds_id";
    296292    $command   .= " -dbname $dbname" if defined $dbname;
  • trunk/ippScripts/scripts/magic_destreak_revert.pl

    r27946 r29561  
    3838
    3939# Parse the command-line arguments
    40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked);
     40my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked, $run_state);
    4141my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum);
    4242my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
     
    4747           'stage=s'        => \$stage,      # raw, chip, warp, or diff
    4848           'stage_id=s'     => \$stage_id,   # exp_id, chip_id, warp_id, or diff_id
     49           'run-state=s'    => \$run_state, # current state of run
    4950           'component=s'    => \$component,  # the class_id or skycell_id
    5051           'path_base=s'    => \$path_base,  # path_base of the input
     
    7475    defined $path_base and
    7576    defined $magicked and
     77    defined $run_state and
    7678    defined $outroot;
    7779
     
    248250{
    249251    my $command = "$magicdstool -revertdestreakedfile -i_am_sure";
     252    $command   .= " -state $run_state";
    250253    $command   .= " -magic_ds_id $magic_ds_id";
    251254    $command   .= " -component $component";
Note: See TracChangeset for help on using the changeset viewer.