geoips.commandline package#
Subpackages#
Submodules#
geoips.commandline.args module#
Command line script for kicking off geoips based procflows.
- geoips.commandline.args.add_args(parser, arglist=None, legacy=False)[source]#
List of available standard arguments for calling data processing command line.
- Parameters:
parser (ArgumentParser) – argparse ArgumentParser to add appropriate arguments
arglist (list, optional) – list of requested arguments to add to the ArgumentParser, default None. if None, include all arguments
legacy (bool, optional) – Represents whether or not a legacy ‘run_procflow’ or ‘data_fusion_procflow’ was called
- Return type:
No return values (parser modified in place)
- geoips.commandline.args.check_command_line_args(arglist, argdict)[source]#
Check formatting of command line arguments.
- Parameters:
arglist (list of str) – List of desired command line arguments to check within argdict for appropriate formatting
argdict (dict) – Dictionary of command line arguments
- Returns:
Return True if all arguments are of appropriate formatting.
- Return type:
bool
- Raises:
TypeError – Incorrect command line formatting
- geoips.commandline.args.get_argparser(arglist=None, description=None, add_args_func=None, check_args_func=None)[source]#
Get argparse.ArgumentParser with all standard arguments added.
- Parameters:
arglist (list, optional) – list of requested arguments to add to the ArgumentParser, default None. if None, include all arguments
description (str, optional) – String description of arguments, default None
add_args_func (function, optional) – Alternative “add_args” function, default None If None, use internal “add_args”
check_args_func (function, optional) – Alternative “check_args” function, default None If None, use internal “check_args”
- Returns:
Including all requested/required command line arguments.
- Return type:
argparse.ArgumentParser
- geoips.commandline.args.get_command_line_args(arglist=None, description=None, add_args_func=None, check_args_func=None)[source]#
Parse command line arguments specified by the requested list of arguments.
- Parameters:
arglist (list, optional) – list of requested arguments to add to the ArgumentParser, default None. if None, include all arguments
description (str, optional) – String description of arguments, default None
add_args_func (function, optional) – Alternative “add_args” function, default None If None, use internal “add_args”
check_args_func (function, optional) – Alternative “check_args” function, default None If None, use internal “check_args”
- Returns:
Dictionary of command line arguments
- Return type:
dict
geoips.commandline.cmd_instructions module#
Module for retrieving help information for the GeoIPS Command Line Interface.
Used to dynamically load and apply help information to all ‘geoips’ commands.
- geoips.commandline.cmd_instructions.get_instructions(ancillary_dirname=None, fname='cmd_instructions.yaml')[source]#
Return a dictionary of instructions for each command, obtained by a yaml file.
This has been placed as a module attribute so we don’t perform this process for every CLI command. It was taking too long to initialize the CLI and this was a large partof that. See NRLMMD-GEOIPS/geoips#444 for more information.
- For more information on what’s available, see:
geoips/commandline/ancillary_info/cmd_instructions.yaml
- Parameters:
ancillary_dirname (str) –
The path to the folder which contains the help instructions for the CLI. Defaults to None in case a user wants to supply a different path for testing purposes
fname (str (optional)) –
The name of the file that we will be checking the modification time of.
- Returns:
cmd_instructions –
Dictionary of help instructions for every CLI command
- Return type:
dict
- geoips.commandline.cmd_instructions.instructions_modified(ancillary_dirname, fname='cmd_instructions.yaml')[source]#
Check whether or not {fname}.yaml has been modified.
This uses os.path.getmtime(fname) determine whether or not the YAML command help instructions have been modified more recently than when we last generated our JSON instructions file. Return the truth value to whether or not cmd_instructions.yaml has been modified more recently than cmd_instructions.json
- Parameters:
ancillary_dirname (str) –
The path to the folder which contains the help instructions for the CLI
fname (str (optional)) –
The name of the file that we will be checking the modification time of.
- Returns:
yaml_recently_modified –
The truth value as to whether or not the yaml cmd_instructions were modified more recently than the json cmd_instructions
- Return type:
bool
geoips.commandline.commandline_interface module#
Code to implement GeoIPS Command Line Interface (CLI).
Will implement a plethora of commands, but for the meantime, we’ll work on ‘geoips list’ and ‘geoips run’
- class geoips.commandline.commandline_interface.GeoipsCLI(instructions_dir=None, legacy=False)[source]#
Bases:
GeoipsCommand
Top-Level Class for the GeoIPS Commandline Interface (CLI).
This class includes a list of Command Classes, which will implement the core functionality of the CLI. This includes the following as of right now: - [GeoipsConfig, GeoipsGet, GeoipsList, GeoipsRun, GeoipsTest, GeoipsValidate]
- command_classes = [<class 'geoips.commandline.geoips_config.GeoipsConfig'>, <class 'geoips.commandline.geoips_describe.GeoipsDescribe'>, <class 'geoips.commandline.geoips_list.GeoipsList'>, <class 'geoips.commandline.geoips_run.GeoipsRun'>, <class 'geoips.commandline.geoips_test.GeoipsTest'>, <class 'geoips.commandline.geoips_tree.GeoipsTree'>, <class 'geoips.commandline.geoips_validate.GeoipsValidate'>]#
- name = 'geoips'#
- geoips.commandline.commandline_interface.main()[source]#
Entry point for GeoIPS command line interface (CLI).
- geoips.commandline.commandline_interface.print_beta_warning()[source]#
Notify the user that the CLI is still in Beta development stage.
- geoips.commandline.commandline_interface.support_legacy_procflows()[source]#
Run a series of checks on sys.argv to support legacy calls to run_procflow.
The new GeoIPS CLI has changed how we run our process workflows from now on. Instead of calling ‘run_procflow’ or ‘data_fusion_procflow’, we now call ‘geoips run single_source’ or ‘geoips run data_fusion’. This function parses through sys.argv and performs the necessary translations to match our current format so that the CLI’s argparser can call the appropriate functionality.
- Returns:
legacy –
The truth value as to whether or not a legacy procflow call was used
- Return type:
bool
geoips.commandline.geoips_command module#
Code to implement GeoipsCommand Abstract Base Class for the CLI.
Will implement a plethora of commands, but for the meantime, we’ll work on ‘geoips config’,’geoips describe’, ‘geoips list’, ‘geoips run’, ‘geoips test’, and ‘geoips validate’.
- class geoips.commandline.geoips_command.CommandClassFactory(base_class, class_name, add_attrs={})[source]#
Bases:
object
An abstract class factory for creating CLI-based Command Classes.
This architecture can be used to generate CLI command classes for specific use cases. A couple which we’ll implement early on is are:
GeoipsListSingleInterface:
GeoipsListSingleInterfaceAlgorithms
GeoipsListSingleInterfaceColormappers
…
GeoipsListSingleInterfaceTitleFormatters
GeoipsDescribeArtifact
GeoipsDescribeArtifactAlgorithm
GeoipsDescribeArtifactColormapper
…
GeoipsDescribeArtifactTitleFormatter
This class has been created to reduce the verbosity of geoips commands without having to copy-paste classes specifc to a certain interface.
- class geoips.commandline.geoips_command.GeoipsCommand(LOG=None, parent=None, legacy=False)[source]#
Bases:
ABC
Abstract Base Class for top-level GeoIPS Command Classes, such as run or list.
This class is a blueprint of what each top-level GeoIPS Command Classes should implement. Includes shared attributes and an
add_suparsers
function which is used for initializing command classes of a certain GeoIPS Command.- add_subparsers()[source]#
Add subparsers for each command class.
This is done so we can limit the scope of what arguments are accepted for each geoips <cmd> command. This is only done for the top-level command, such as “list”, “run”, “describe”, etc.
For example, if this were the GeoipsList Command Class, we would create a self.list_subparsers attribute, which we then add individual parsers for each command, as in interfaces, plugins, packages, scripts, etc.
- abstract property command_classes#
List of command_classes related to the top level command.
For example, if the class provided was GeoipsList, command_classes would be the list of available command_classes that “geoips list” implements.
- abstract property name#
Name of the command class.
- property plugin_package_names#
List of names of all installed Geoips Plugin Packages.
- property plugin_package_paths#
List of paths to all installed Geoips Plugin Packages.
- class geoips.commandline.geoips_command.GeoipsExecutableCommand(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsCommand
Abstract Base Class for executable CLI commands, inheriting from GeoipsCommand.
This class is a blueprint of what each executable GeoIPS Command Classes can implement.
- abstract add_arguments()[source]#
Add arguments related to the command class.
This is an abstract method because we don’t know which arguments need to be added for each class at this moment.
- property terminal_width#
The Width in ANSI-Characters of the User’s Terminal.
Generate this every time as the screen width may change during usage.
- class geoips.commandline.geoips_command.ParentParsers[source]#
Bases:
object
Object containing shared arguments for commands in a hierarchical order.
The name of the parsers in this class directly link to the name of the top-level command which will share its arguments. For example, since our top-level command is ‘geoips’ (see GeoipsCLI), then the arguments created by ‘geoips_parser’ will be shared amongst all of its child commands. As such, every argument created by ‘list_parser’ will be shared by ‘list’ commands, and so on. So long as the name of the class matches the structure <class_name>_parser, then the arguments will be shared correctly.
- geoips_parser = ArgumentParser(prog='build_docs.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)#
- list_parser = ArgumentParser(prog='build_docs.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False)#
- mutex_group = <argparse._MutuallyExclusiveGroup object>#
- class geoips.commandline.geoips_command.PluginPackages[source]#
Bases:
object
Class to hold the plugin packages and their paths.
This class is used to hold the plugin packages and their paths, which are used throughout the CLI to determine which plugins are available to the user. This class is used in the GeoipsCLI class to determine which plugins are available to the user.
Moving this to a class reduced GeoIPS CLI startup time by about 30%.
geoips.commandline.geoips_config module#
GeoIPS CLI “config” command.
Various configuration-based commands for setting up your geoips environment.
- class geoips.commandline.geoips_config.GeoipsConfig(LOG=None, parent=None, legacy=False)[source]#
Bases:
GeoipsCommand
Config top-level command for configuring your GeoIPS environment.
- command_classes = [<class 'geoips.commandline.geoips_config.GeoipsConfigInstall'>]#
- name = 'config'#
- class geoips.commandline.geoips_config.GeoipsConfigInstall(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Config Command Class for installing packages/data.
Supports installation of packages and test data needed for testing and/or running your GeoIPS environment.
- command_classes = []#
- download_extract_test_data(url, download_dir)[source]#
Download the specified URL and write it to the corresponding download_dir.
Will extract the data using tarfile and create an archive by bundling the associated files and directories together.
- Parameters:
url (str) –
The url of the test dataset to download
download_dir (str) –
The directory in which to download and extract the data into
- extract_data_cautiously(response, download_dir)[source]#
Extract the GET Response cautiously and skip any dangerous members.
Iterate through a Response and check that each member is not dangerous to extract to your machine. If it is, skip it.
Where ‘dangerous’ is a filepath that is not part of ‘download_dir’. File path maneuvering characters could be invoked (‘../’, …), which we will not allow when downloading test data.
- Parameters:
response (Requests Response Object) –
The GET Response from retrieving the data url
download_dir (str) –
The directory in which to download and extract the data into
- property geoips_testdata_dir#
String path to GEOIPS_TESTDATA_DIR.
- name = 'install'#
geoips.commandline.geoips_describe module#
GeoIPS CLI “describe” command.
Retrieves the appropriate family/interface/package/plugin based on the args provided.
- class geoips.commandline.geoips_describe.GeoipsDescribe(LOG=None, parent=None, legacy=False)[source]#
Bases:
GeoipsCommand
Top-Level Describe Command Class for retrieving info about GeoIPS Artifacts.
- command_classes = [<class 'abc.GeoipsDescribeArtifactAlgorithms'>, <class 'abc.GeoipsDescribeArtifactColormappers'>, <class 'abc.GeoipsDescribeArtifactCoverage-Checkers'>, <class 'abc.GeoipsDescribeArtifactDatabases'>, <class 'abc.GeoipsDescribeArtifactFeature-Annotators'>, <class 'abc.GeoipsDescribeArtifactFilename-Formatters'>, <class 'abc.GeoipsDescribeArtifactGridline-Annotators'>, <class 'abc.GeoipsDescribeArtifactInterpolators'>, <class 'abc.GeoipsDescribeArtifactOutput-Checkers'>, <class 'abc.GeoipsDescribeArtifactOutput-Formatters'>, <class 'abc.GeoipsDescribeArtifactProcflows'>, <class 'abc.GeoipsDescribeArtifactProduct-Defaults'>, <class 'abc.GeoipsDescribeArtifactProducts'>, <class 'abc.GeoipsDescribeArtifactReaders'>, <class 'abc.GeoipsDescribeArtifactSector-Adjusters'>, <class 'abc.GeoipsDescribeArtifactSector-Metadata-Generators'>, <class 'abc.GeoipsDescribeArtifactSector-Spec-Generators'>, <class 'abc.GeoipsDescribeArtifactSectors'>, <class 'abc.GeoipsDescribeArtifactTitle-Formatters'>, <class 'abc.GeoipsDescribeArtifactWorkflows'>, <class 'geoips.commandline.geoips_describe.GeoipsDescribePackage'>]#
- generated_classes = [<class 'abc.GeoipsDescribeArtifactAlgorithms'>, <class 'abc.GeoipsDescribeArtifactColormappers'>, <class 'abc.GeoipsDescribeArtifactCoverage-Checkers'>, <class 'abc.GeoipsDescribeArtifactDatabases'>, <class 'abc.GeoipsDescribeArtifactFeature-Annotators'>, <class 'abc.GeoipsDescribeArtifactFilename-Formatters'>, <class 'abc.GeoipsDescribeArtifactGridline-Annotators'>, <class 'abc.GeoipsDescribeArtifactInterpolators'>, <class 'abc.GeoipsDescribeArtifactOutput-Checkers'>, <class 'abc.GeoipsDescribeArtifactOutput-Formatters'>, <class 'abc.GeoipsDescribeArtifactProcflows'>, <class 'abc.GeoipsDescribeArtifactProduct-Defaults'>, <class 'abc.GeoipsDescribeArtifactProducts'>, <class 'abc.GeoipsDescribeArtifactReaders'>, <class 'abc.GeoipsDescribeArtifactSector-Adjusters'>, <class 'abc.GeoipsDescribeArtifactSector-Metadata-Generators'>, <class 'abc.GeoipsDescribeArtifactSector-Spec-Generators'>, <class 'abc.GeoipsDescribeArtifactSectors'>, <class 'abc.GeoipsDescribeArtifactTitle-Formatters'>, <class 'abc.GeoipsDescribeArtifactWorkflows'>]#
- int_name = 'workflows'#
- name = 'describe'#
- class geoips.commandline.geoips_describe.GeoipsDescribeArtifact(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Command which returns information describing a GeoIPS artifact.
Where this artifact is one of [‘interface’, ‘plugin’, ‘family’.]
This is called via geoips describe <interface_name> <opt_args>. Data included when calling this command is shown below, outputted in a yaml-based format.
- Interface:
- Command Signature:
geoips describe <interface_name>
- Artifact Listing:
geoips list interfaces
- output_info:
Absolute Path
Docstring
Interface Name
Interface Type
Supported Families
- Plugin:
- Command Signature:
geoips describe <interface_name> <plugin_name>
- Artifact Listing:
geoips list plugins <-p> <package_name>
- Output Info:
Docstring
Family Name
GeoIPS Package
Interface Name
Plugin Type
call_sig / source_names / Product Defaults (dependent on Plugin Type)
Relative Path
- Family:
- Command Signature:
geoips describe <interface_name> family <family_name>
- Artifact Listing:
geoips list interfaces –columns interface supported_families
- Output Info:
Docstring
Family Name
Family Path
Interface Name
Interface Type
Required Arguments / Schema
- command_classes = []#
- describe_family(args)[source]#
CLI ‘geoips describe <interface_name> family <family_name>’ command.
This occurs when a user has requested a family in the manner shown above. Outputs to the teriminal the following data in a dictionary format if available.
Printed to Terminal#
- yaml-based output: dict
Docstring
Family Name
Family Path
Interface Name
Interface Type
Required Arguments / Schema
- param args:
The list argument namespace to parse through
- type args:
Argparse Namespace()
- describe_interface()[source]#
CLI ‘geoips describe <interface_name>’ command.
This occurs when a user has requested a interface in the manner shown above. Outputs to the teriminal the following data in a dictionary format if available.
Printed to Terminal#
- yaml-based output: dict
Absolute Path
Docstring
Interface Name
Interface Type
Supported Families
- describe_plugin(args)[source]#
CLI ‘geoips describe <interface_name> <plugin_name>’ command.
This occurs when a user has requested a plugin in the manner shown above. Outputs to the teriminal the following data in a dictionary format if available.
Printed to Terminal#
- yaml-based output: dict
Docstring
Family Name
GeoIPS Package
Interface Name
Plugin Type
call_sig / source_names / Product Defaults (dependent on Plugin Type)
Relative Path
- param args:
The list argument namespace to parse through
- type args:
Argparse Namespace()
- ensure_plugin_exists(interface_name, interface_registry, plugin_name)[source]#
Ensure that the given plugin exists within an interface’s plugin registry.
If the plugin is not found within the interface’s registry, raise a KeyError, otherwise, just return.
- Parameters:
interface_name (str) –
The name of the selected GeoIPS Interface
interface_registry (dict) –
The plugin registry for the selected GeoIPS Interface
plugin_name (str) –
The name of the plugin from the selected interface
- name = 'interface'#
- class geoips.commandline.geoips_describe.GeoipsDescribePackage(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Describe Command which retrieves information about a certain GeoIPS Package.
This is called via geoips describe package <interface_name>. Data included when calling this command is shown below, outputted in a yaml-based format.
- command_classes = []#
- name = 'package'#
geoips.commandline.geoips_list module#
GeoIPS CLI “list” command.
Lists the appropriate interfaces/packages/plugins based on the arguments provided.
- class geoips.commandline.geoips_list.GeoipsList(LOG=None, parent=None, legacy=False)[source]#
Bases:
GeoipsCommand
Top-Level List Command for listing off GeoIPS Artifacts.
- command_classes = [<class 'abc.GeoipsListSingleInterfaceAlgorithms'>, <class 'abc.GeoipsListSingleInterfaceColormappers'>, <class 'abc.GeoipsListSingleInterfaceCoverage-Checkers'>, <class 'abc.GeoipsListSingleInterfaceDatabases'>, <class 'abc.GeoipsListSingleInterfaceFeature-Annotators'>, <class 'abc.GeoipsListSingleInterfaceFilename-Formatters'>, <class 'abc.GeoipsListSingleInterfaceGridline-Annotators'>, <class 'abc.GeoipsListSingleInterfaceInterpolators'>, <class 'abc.GeoipsListSingleInterfaceOutput-Checkers'>, <class 'abc.GeoipsListSingleInterfaceOutput-Formatters'>, <class 'abc.GeoipsListSingleInterfaceProcflows'>, <class 'abc.GeoipsListSingleInterfaceProduct-Defaults'>, <class 'abc.GeoipsListSingleInterfaceProducts'>, <class 'abc.GeoipsListSingleInterfaceReaders'>, <class 'abc.GeoipsListSingleInterfaceSector-Adjusters'>, <class 'abc.GeoipsListSingleInterfaceSector-Metadata-Generators'>, <class 'abc.GeoipsListSingleInterfaceSector-Spec-Generators'>, <class 'abc.GeoipsListSingleInterfaceSectors'>, <class 'abc.GeoipsListSingleInterfaceTitle-Formatters'>, <class 'abc.GeoipsListSingleInterfaceWorkflows'>, <class 'geoips.commandline.geoips_list.GeoipsListInterfaces'>, <class 'geoips.commandline.geoips_list.GeoipsListPackages'>, <class 'geoips.commandline.geoips_list.GeoipsListPlugins'>, <class 'geoips.commandline.geoips_list.GeoipsListScripts'>, <class 'geoips.commandline.geoips_list.GeoipsListSourceNames'>, <class 'geoips.commandline.geoips_list.GeoipsListTestDatasets'>, <class 'geoips.commandline.geoips_list.GeoipsListUnitTests'>]#
- generated_classes = [<class 'abc.GeoipsListSingleInterfaceAlgorithms'>, <class 'abc.GeoipsListSingleInterfaceColormappers'>, <class 'abc.GeoipsListSingleInterfaceCoverage-Checkers'>, <class 'abc.GeoipsListSingleInterfaceDatabases'>, <class 'abc.GeoipsListSingleInterfaceFeature-Annotators'>, <class 'abc.GeoipsListSingleInterfaceFilename-Formatters'>, <class 'abc.GeoipsListSingleInterfaceGridline-Annotators'>, <class 'abc.GeoipsListSingleInterfaceInterpolators'>, <class 'abc.GeoipsListSingleInterfaceOutput-Checkers'>, <class 'abc.GeoipsListSingleInterfaceOutput-Formatters'>, <class 'abc.GeoipsListSingleInterfaceProcflows'>, <class 'abc.GeoipsListSingleInterfaceProduct-Defaults'>, <class 'abc.GeoipsListSingleInterfaceProducts'>, <class 'abc.GeoipsListSingleInterfaceReaders'>, <class 'abc.GeoipsListSingleInterfaceSector-Adjusters'>, <class 'abc.GeoipsListSingleInterfaceSector-Metadata-Generators'>, <class 'abc.GeoipsListSingleInterfaceSector-Spec-Generators'>, <class 'abc.GeoipsListSingleInterfaceSectors'>, <class 'abc.GeoipsListSingleInterfaceTitle-Formatters'>, <class 'abc.GeoipsListSingleInterfaceWorkflows'>]#
- int_name = 'workflows'#
- name = 'list'#
- class geoips.commandline.geoips_list.GeoipsListInterfaces(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing interfaces and interface-specific plugins.
Will either list information about available GeoIPS interfaces (done via geoips list interfaces), or list information about implemented interface-specific plugins implemented in all, or a certain package (done via ‘geoips list interfaces -i <-p> <package_name>’).
Called via geoips list interfaces. Outputs the following data in a tabular format.
- command_classes = []#
- list_available_interfaces(args)[source]#
List the available interface[s] within [a] GeoIPS Package[s]”.
Printed to Terminal#
- out_array: 2D Array of Strings
Absolute Path
Docstring
GeoIPS Package
Interface Type
Interface Name
Supported Families
- param args:
The arguments provided to a certain list command
- type args:
argparse Argument Namespace
- list_implemented_interfaces(package_name, args)[source]#
List the implemented interface[s] within [a] GeoIPS Package[s].
Ie. search through all, or an individual package and list off what has been implemented in such package[s].
Printed to Terminal#
- out_array: 2D Array of Strings
GeoIPS Package
Interface Type
Interface Name
- param package_name:
The GeoIPS Package name whose scripts you want to list.
- type package_name:
str
- param args:
The arguments provided to a certain list command
- type args:
argparse Argument Namespace
- name = 'interfaces'#
- class geoips.commandline.geoips_list.GeoipsListPackages(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing off installed GeoIPS Packages.
Called via geoips list packages. Outputs the following data in a tabular format.
- command_classes = []#
- name = 'packages'#
- class geoips.commandline.geoips_list.GeoipsListPlugins(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing off plugins in all, or a certain GeoIPS Package.
Called via geoips list plugins. Outputs the following data in a tabular format.
- command_classes = []#
- name = 'plugins'#
- class geoips.commandline.geoips_list.GeoipsListScripts(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing test scripts from all, or a certain GeoIPS Package.
Called via geoips list scripts. Outputs the following data in a tabular format.
- command_classes = []#
- name = 'scripts'#
- class geoips.commandline.geoips_list.GeoipsListSingleInterface(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing plugins of a single interface.
- add_arguments()[source]#
Instantiate the valid arguments that are supported for the list command.
- Currently the “geoips list interface” command supports this format:
geoips list interface <interface_name> -p <package_name>
- Where:
<interface_name> is any of the GeoIPS Interfaces’ Name
<package_name> is any GeoIPS package that is installed and recognized by the GeoIPS Library
- command_classes = []#
- name = 'interface'#
- class geoips.commandline.geoips_list.GeoipsListSourceNames(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing out source_names from available reader plugins.
This command is used to easily expose what source_names are supported by each reader. If a reader module is missing the source_name attribute, then that will be notified in the CLI output.
- command_classes = []#
- match_readers_with_source_name(registry)[source]#
Assemble a dictionary of <source_name>:[readers] for tabular listing.
Match source_names found in the registry to readers which support that source_name. Each key in the dictionary will be a unique source_name with values that are the names of readers which support that source_name.
- Parameters:
registry (dict) –
The readers portion of all GeoIPS plugin packages’ plugin registries or a single package’s plugin registry.
- Returns:
src_name_mapping –
A dictionary mapping of source_name:[readers] which links readers to a unique source_name which they support.
- Return type:
dict
- name = 'source-names'#
- class geoips.commandline.geoips_list.GeoipsListTestDatasets(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing off available test-datasets used by GeoIPS.
Called via geoips list test-datasets. Outputs the following in a tabular format.
- add_arguments()[source]#
Add arguments to the list-subparser for the List Test Datasets Command.
Since this command requires no additional arguments, we pass for the time being.
- command_classes = []#
- name = 'test-datasets'#
- class geoips.commandline.geoips_list.GeoipsListUnitTests(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
List Command for listing out available unit tests.
Called via geoips list unit-tests. Outputs the following in a tabular format.
- command_classes = []#
- name = 'unit-tests'#
geoips.commandline.geoips_run module#
GeoIPS CLI “run” command.
Runs the appropriate script based on the args provided.
- class geoips.commandline.geoips_run.GeoipsRun(LOG=None, parent=None, legacy=False)[source]#
Bases:
GeoipsCommand
Run Command for running process-workflows (procflows).
- command_classes = [<class 'geoips.commandline.geoips_run.GeoipsRunSingleSource'>, <class 'geoips.commandline.geoips_run.GeoipsRunDataFusion'>, <class 'geoips.commandline.geoips_run.GeoipsRunConfigBased'>]#
- name = 'run'#
- class geoips.commandline.geoips_run.GeoipsRunConfigBased(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Run Command for executing the config based process-workflow (procflow).
- command_classes = []#
- name = 'config_based'#
- class geoips.commandline.geoips_run.GeoipsRunDataFusion(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Run Command for executing the data fusion process-workflow (procflow).
- command_classes = []#
- name = 'data_fusion'#
- class geoips.commandline.geoips_run.GeoipsRunSingleSource(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Run Command for executing the single source process-workflow (procflow).
- command_classes = []#
- name = 'single_source'#
geoips.commandline.geoips_test module#
GeoIPS CLI “test” command.
Runs the appropriate tests based on the arguments provided.
- class geoips.commandline.geoips_test.GeoipsTest(LOG=None, parent=None, legacy=False)[source]#
Bases:
GeoipsCommand
Top-Level Test Command for testing GeoIPS and its corresponding Packages.
- command_classes = [<class 'geoips.commandline.geoips_test.GeoipsTestLinting'>, <class 'geoips.commandline.geoips_test.GeoipsTestScript'>, <class 'geoips.commandline.geoips_test.GeoipsTestSector'>]#
- name = 'test'#
- class geoips.commandline.geoips_test.GeoipsTestLinting(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Test Command for running GeoIPS Linting Services.
- command_classes = []#
- name = 'linting'#
- class geoips.commandline.geoips_test.GeoipsTestScript(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Test Command for running GeoIPS Test Scripts.
- add_arguments()[source]#
Instantiate the arguments that are supported for the test script command.
- Currently the “geoips test script” command supports this format:
geoips test script <-p> <package_name> <script_name> <–integration>
- Where:
<package_name> is any GeoIPS package that is installed and recognized by the GeoIPS Library
<script_name> is the name of the bash script being tested
‘–integration’ represents whether or not this is an ‘integration’ test
- command_classes = []#
- name = 'script'#
- class geoips.commandline.geoips_test.GeoipsTestSector(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Test Command for creating a sector image based on the provided sector name.
This used to be ran via ‘create_sector_image’, however we are trying to consolidate all independent console scripts to be used via the CLI. When this command is called an image of the provided sector will be created so we can view whether or not it matches the region of the globe we’d like to study.
- add_arguments()[source]#
Instantiate the arguments that are supported for the test sector command.
- Currently the “geoips test sector” command supports this format:
geoips test sector <sector_name> –outdir <output_directory_path>
- Where:
<sector_name> is the name of any GeoIPS Sector Plugin that has an entry in any package’s plugin registry.
–outdir is the full path to the directory in which you’d like to create the sector image.
- command_classes = []#
- name = 'sector'#
geoips.commandline.geoips_tree module#
GeoIPS CLI “tree” command.
Single ‘geoips tree’ command which will display GeoIPS CLI commands up to a –max-depth value.
- class geoips.commandline.geoips_tree.GeoipsTree(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Tree Command Class for displaying GeoIPS CLI commands in a tree-like fashion.
Can be configured to print in a colored fashion, up to a maximum depth, and whether or not we want the full command string or just the command name at it’s depth.
Where depth denotes the level of the command you’d like to display. I.e. <0> geoips <1> list <2> scripts
- property cmd_aliases#
List of aliases we don’t want to include in the tree.
Without this attribute there will be an entry for each alias of a command name. So for ‘list’ (or ‘ls’), there will be two ‘geoips list’ entries which we don’t want.
- property cmd_line_url#
The url to the GeoIPS documentation for the GeoIPS CLI.
- command_classes = []#
- describe_sectors_outputted = False#
- property level_to_color#
A color-mapping dictionary based on the depth of the command tree.
- link(uri, label=None)[source]#
Hyperlink the provided uri alongside ‘label’ if applicable.
If label is not provided, just return a hyperlink with ‘url’ as it’s text.
- Parameters:
uri (str) –
The uniform resource identifier which maps to a certain webpage.
label (str (default = None)) –
Optional text to hyperlink to.
- Returns:
hyperlink –
Text that has been hyperlinked to ‘uri’
- Return type:
str
- list_sectors_outputted = False#
- name = 'tree'#
- print_tree(parser, color=False, level=0, max_depth=2, short_name=False)[source]#
Display GeoIPS CLI commands up to ‘max_depth’ in a tree-like fashion.
This function is recursively called up to ‘max_depth’ to generate that tree of commands. If wanted, we can color the output of the tree by depth and we can also control whether or not we want the full command string or just the command name by depth.
- Parameters:
parser (argparse.ArgumentParser) –
The parser associated with the command at the current depth.
color (bool) –
Whether or not we want the output to be colored by depth.
level (int) –
The current depth of the command tree (starts at 0).
max_depth (int) –
How deep we would like to expose the command tree
short_name –
Whether or not we want the full command string or just the command name at it’s depth.
Ex: short_name=False -> ‘geoips config install’
Ex: short_name=True -> ‘install’
- property top_level_parser#
The parser associated with the top level ‘geoips’ command.
geoips.commandline.geoips_validate module#
GeoIPS CLI “validate” command.
Validates the appropriate plugin based on the arguments provided using the associated interface’s validation mechaninism (interface.plugin_is_valid(plugin_name)).
- class geoips.commandline.geoips_validate.GeoipsValidate(LOG, parent=None, legacy=False)[source]#
Bases:
GeoipsExecutableCommand
Validate Command for validating package plugins.
- command_classes = []#
- get_interface_and_plugin(fpath, plugin_name=None)[source]#
Retrieve the interface and plugin associated with the file path given.
- Parameters:
fpath (str) –
The file path of the plugin requested to be validated.
plugin_name (str, default=None) –
If provided and the filepath is a .yaml file, assume this is a multi-document yaml file (such as a workflow plugin), and attempt to find the plugin matching ‘plugin_name’ in that document.
- Returns:
interface (GeoIPS Interface Class) –
The interface associated with the provided plugin.
plugin (Python Module or Yaml Dictionary) –
The plugin “definition” associated with the file path provided.
plugin_name (str) –
The name of the plugin
- name = 'validate'#
- validate_sub_products(interface, fpath, plugin)[source]#
Validate each sub-product plugin found within a products yaml definition.
If the corresponding interface was found to be a “products” interface, validate each sub-product plugin found within the provided yaml products plugin.
- Parameters:
interface (GeoIPS Interface Class) –
GeoIPS Products Interface used for validation
fpath (str) –
The file path of the products plugin to be validated
plugin (dict) –
Dictionary representing the Products’ yaml file provided.
- Returns:
True or False, where True means that every sub-plugin is valid and False means that at least a single sub-plugin was invalid.
- Return type:
bool
geoips.commandline.list_available_plugins module#
Simple script to list available plugins for each interface.
geoips.commandline.log_setup module#
Geoips module for setting up logging handlers with a specified verbosity.
- class geoips.commandline.log_setup.LogLevelAdder[source]#
Bases:
object
Create a callable that can add a new logging level.
Initialize simply as add_log_level = LogLevelAdder() and add a new level by calling add_log_level with the name of the new log level and its level number.
For further call information, see the docstring for LogLevelAdder.__call__().
- geoips.commandline.log_setup.log_with_emphasis(print_func, *messages)[source]#
Print messages boxed in asterisks using the specified print function.
Print one or more messages using the specified print function. The messages will be surrounded in asterisks. Long messages will be word wrapped to fit within a maximum width of 74 characters, save for any individual words that are over 74 characters which will not be broken.
- Parameters:
print_func (func) – An instance of a function that prints (e.g.
logging.debug
,logging.info
, etc, or theprint
function itself).messages (one or more strings) – The messages to be logged with emphasis
- geoips.commandline.log_setup.setup_logging(logging_level=None, fmt_string=None, datefmt_string=None)[source]#
Get a new logger instance for GeoIPS.
Get a new logger instance for GeoIPS. This will set the logger’s logging level, its formatter, and add a StreamHandler pointing to sys.stdout.
This is most often used at the top-level of an applcation to set up the root logger for the application (e.g. in a command line script). Once configured, the root logger’s properties will be inherited by lower-level logger instances. So, to use the same logging configuration in submodules, simply instantiate a new logger instance via LOG = logging.getLogger(__name__) and it will behave the same as the root logger.
- Parameters:
logging_level (str, default=None) – Sets the minimum log level for which log output will be written to stdout. If None, will default to value set in base_paths. This allows using GEOIPS_LOGGING_LEVEL to override default.
fmt_string (str, default=None) – Explicitly specify the log formatter format string. If None, default to the value set in geoips/filenames/base_paths (which in the future will be replaced with a GeoIPS config file).
datefmt_string (str, default=None) – Explicitly specify the log formatter datefmt string. If None, default to the value set in geoips/filenames/base_paths (which in the future will be replaced with a GeoIPS config file).
geoips.commandline.run_procflow module#
Command line script for kicking off geoips based procflows.
MUST call with –procflow.
- geoips.commandline.run_procflow.main(get_command_line_args_func=None, ARGS=None)[source]#
Script to kick off processing based on command line args.
- Parameters:
get_command_line_args_func (function, optional) –
Function to use in place of “get_command_line_args”, default None If None, use geoips.commandline.args.get_command_line_args
ARGS (argparse Namespace) –
The arguments provided to ‘geoips run’ / ‘run_procflow’. If ARGS are provided, this means we have called this function via ‘geoips run’ and the arguments were obtained via the GeoIPS CLI alongside geoips.commandline.args:add_args For more info, see geoips.commandline.geoips_run.GeoipsRun:add_arguments
geoips.commandline.update_tc_tracks_database module#
Command line script for updating the TC database.
Module contents#
geoips.commandline init file.