pds.naif_pds4_bundler.classes package

Submodules

pds.naif_pds4_bundler.classes.bundle module

Bundle Class Implementation.

class pds.naif_pds4_bundler.classes.bundle.Bundle(setup)[source]

Bases: object

Class to generate the PDS4 Bundle structure.

The class construction will generate the top level directory structure for a PDS4 bundle or a PDS3 data set.

Parameters:

setup – NPB execution Setup

add(element)[source]

Add a Collection to the Bundle.

check_times()[source]

Check the correctness of the bundle times.

copy_to_bundle()[source]

Copy files from staging_directory to the bundle_directory.

files_in_staging()[source]

Lists all the files in the staging area.

get_history(object)[source]

This method builds the “Archive History”.

The “Archive history” is obtained by extracting the previous releases and the Collections that correspond to each release from the Bundle labels. The other products’ information is extracted from the collection inventories.

The archive history is then provided as a dictionary with releases as keys and each key contains a list of files for that release.

The method checks whether if there is any duplicated element.

Parameters:

object – optional Bundle object for tests

Returns:

Archive history dictionary

Return type:

dict

set_bundle_lid()[source]

Set the Bundle LID.

set_bundle_vid()[source]

Set the Bundle VID.

validate()[source]

Validate the Bundle.

The two implemented steps are to check checksum files against the updated bundle history and checking the bundle times.

validate_history()[source]

Validate the bundle updated history with the checksum files.

This method validates all the archive Checksum files with the “Archive History”. The “Archive history” is obtained by extracting the previous releases and the Collections that correspond to each release from the Bundle labels. The other products’ information is extracted from the collection inventories.

The archive history is then provided as a dictionary with releases as keys and each key contains a list of files for that release.

The validation is performed by comparing each release entry of the dictionary with the release checksum file checksum_v???.tab.

In parallel the method writes in the execution log the complete bundle release history, providing an ordered list of files released for each release number.

write_readme()[source]

Write the readme product if it does not exist.

pds.naif_pds4_bundler.classes.collection module

pds.naif_pds4_bundler.classes.label module

pds.naif_pds4_bundler.classes.list module

Implementation of the Kernel List class.

class pds.naif_pds4_bundler.classes.list.KernelList(setup)[source]

Bases: object

Class to generate a Kernel List.

Parameters:

setup – NPB execution setup object

add(kernel: str) None[source]

Add SPICE kernel or OrbNum file to the list.

Parameters:

kernel – SPICE kernel or OrbNum file added to the list

check_products()[source]

Check the SPICE kernel and ORBNUM products from the kernel list.

The products present in the Kernel List –whether if generated by NPB or provided by the user– will be checked and if issues are found they will be reported as WARNING or ERROR messages.

The checks performed to the products are the following:

  • identify if a SPICE kernel is present in multiple kernel directories

  • check End of Line character for text SPICE kernels and ORBNUM files.

  • check text SPICE kernels and ORBNUM files for non-ASCII characters.

  • check if text SPICE kernels have more than 80 characters per line.

  • validate kernel architecture

  • check endianness and permissions of binary kernels

read_config() None[source]

Extract the Kernel List information from the configuration file.

read_list(kerlist)[source]

Read the Kernel List.

Note that the format that the kernel list has to follow is very strict, including no whitespace at the end of each line and Line-feed EOL.

Parameters:

kerlist (str) – Kernel List path

read_plan(plan)[source]

Read Release Plan from the main module input.

Parameters:

plan (str) – Release Plan name

validate()[source]

Validation of the Kernel List.

The validation of the Kernel List performs the following checks:

  • check that the list has the same number of FILE, MAKLABEL_OPTIONS, and DESCRIPTION entries.

  • check list against plan

  • check that list for duplicate files

  • check that all files listed in the list are on the kernels_directory

  • check that the files are not in the bundle_directory

  • display all the MAKLABL_OPTIONS used

  • check that all the MAKLBL_OPTIONS are in the template for PDS3

  • check that the list has no duplicates

  • check that the list has no bad characters

  • if the -d DIFF --diff DIFF argument is used, compare the kernel list with the kernel list of the previous release -if avaialble.

validate_complete()[source]

Validation of the complete Kernel List.

The complete Kernel List is generated by NPB by merging all the available Kernel List files. These kernel list files must be located in the working_directory as specified by the NPB configuration.

In principle all the kernels that have ever been added to the archive should be present.

The validation of the complete Kernel List performs the following checks:

  • check that the list has the same number of FILE, MAKLABEL_OPTIONS, and DESCRIPTION entries

  • check all the MAKLABL_OPTIONS used

  • check that the list has no duplicates

write_complete_list()[source]

Write the complete Kernel List using the former ones.

write_list()[source]

Write the Kernel List product.

The list is not an archival product but an NPB by-product, therefore it is not generated by any of the product classes.

write_plan()[source]

Write the Release Plan if not provided.

Returns:

True if a release plan has been generated, False if it has been provided as input

Return type:

bool

pds.naif_pds4_bundler.classes.log module

Log Class Implementation.

class pds.naif_pds4_bundler.classes.log.Log(setup: Setup, args: PipelineArgs)[source]

Bases: object

Log class to write and output NPB’s log.

Parameters:
  • setup – Setup object from NPB’s main function.

  • args – Command line arguments from NPB’s main function.

start() None[source]

Start the generation of the log for the execution.

stop() None[source]

Write log, file list, and checksum registry files when NPB stops.

Side effects:
  • Removes template files

  • Writes the run-by product file list and checksum record

  • Writes a PDS validate tool configuration file, if applicable

  • Clears SPICE kernel pool

  • Renames the temporary log file

pds.naif_pds4_bundler.classes.log.error_message(message: str, setup: Setup | None = None) None[source]

Signal a NPB error and write run artifacts.

Side effects:
  • Writes file list and checksum registry if setup is provided

  • Removes template files

  • Clears SPICE kernel pool

  • Raises RuntimeError

Parameters:
  • message – Error message

  • setup – Optional Setup object for writing artifacts

Raises:

RuntimeError – always, with the provided error message.

pds.naif_pds4_bundler.classes.object module

Dummy Class Implementation.

class pds.naif_pds4_bundler.classes.object.Object[source]

Bases: object

Dummy Class.

pds.naif_pds4_bundler.classes.product module

pds.naif_pds4_bundler.classes.setup module

Setup Class Implementation.

class pds.naif_pds4_bundler.classes.setup.Setup(args, version: str)[source]

Bases: object

Class that parses and processes the NPB XML configuration file.

Parameters:
  • args – Parameters arguments from NPB main function

  • version (str) – NPB version

add_checksum(path, checksum)[source]

Add checksum to Checksum record.

Adds a MD5sum entry with the product it corresponds to for the run by-product Checksum record file.

Parameters:
  • path (str) – File path for checksum

  • checksum (str) – Checksum value for checksum

add_file(file)[source]

Add file fo Product List.

Adds a product to the run by-product Product List.

Parameters:

file (str) – Product to be added

check_configuration()[source]

Performs the following checks to the loaded configuration items:

  • IM, Line Feed, and Date Time format NAIF recommendations

  • Archive increment start and finish times

  • Transform relative to absolute paths

  • Existence of kernel directories

  • IM, XML model, and Schema Location coherence

  • Check existence of templates according to the IM

  • Meta-kernel configuration

  • Presence of uppercase characters in the kernel list configuration

clear_run(debug=False)[source]

Clears the files generated by a previous run.

Clears the files generated by a previous run when specified with the clear argument and the kernel list of the previous run.

Please note that newly created directories will not be erased.

Parameters:

debug (bool) – If True, the by-product files are not cleaned up. This is useful when testing

information_model_setup()[source]

Setup and check PDS4 Information Model related things.

load_kernels()[source]

Loads the kernels required to run NPB.

Note that kernels that are not required might be loaded as well, but given that the required memory is not much, we stay on the safe side by loading additional kernels.

set_release()[source]

Determine the Bundle release number.

write_checksum_registry()[source]

Write the run by-product Checksum Record.

write_file_list()[source]

Write the run by-product File List.

write_validate_config()[source]

Write a PDS validate tool configuration file.

NPB will write a PDS validate tool configuration file for convenience of the user. The following validate example command for ExoMars2016:

$ validate -v 1 -t em16/em16_spice -R pds4.bundle -x             working/PDS4_PDS_1B00.xsd -S working/PDS4_PDS_1B00.sch            -–strict-field-checks -r working/em16_release_03.validate

Would be equivalent to the following resulting Validate configuration file:

# Run the PDS validate tool where the NPB working directory resides:
# $ validate -c working/em16_release_03.config.validate
validate.target = em16/em16_spice
validate.verbose = 1
validate.rule = pds4.bundle
validate.schema = working/PDS4_PDS_1B00.xsd
validate.schematron = working/PDS4_PDS_1B00.sch
validate.strictFieldChecks = true
validate.report = working/em16_release_03.validate_report

If there is an issue during the generation of this file –e.g.: no internet connection– the process will silently fail but the NPB run will be successful.

Module contents

NAIF PDS4 Bundle Classes Namespace.

The NPB Classes implement the main functionalities of the pipeline.