This template provides the basic environment and framework for an orekit-based application written in python.
Simply click the green "Use this template" button to get started, then, follow these instructions:
- Rename the
app_name
directory to your application name. - Update
pyproject.toml
by:- Update the application name and description on lines 6 and 7.
- Update the author(s) on line 9.
- Update the app_name on line 31 to the new application directory value from step 1.
- Update
environment.yaml
by:- Updating the environment name on line 1.
- Adding any additional dependencies you know at the start.
- Update
src/__main__.py
by:- Updating the import on line 4 with the application directory name from step 1.
- Update
src/utils/logging.py
by:- Updating the logger on line 24, replacing *app_name_ with the application directory name fro step 1.
- Delete this list and update this
readme.md
with app-specific details. - Write your application code in the
.apps
module. See the examples, or the section below
A modules in the apps
module is a python file containing functions of specific names.
execute(vm=None, args:argparse.Namespace=None, config:dict=None)
- This is the application entrypoint. It takes 3 keyword parameters:vm
is the handle returned byorekit.initVM()
, this can be used to register subthreads in the applicationargs
the parsed command line argumentsconfig
the parsed contents of theconfig.yaml
file, if one was loaded,None
otherwise
An additional method may optionally be specified:
config_args(parser)
- This method is called with the argument parser from argparse. Implement this method to add application-specific command line arguments.
This framework supports multiple apps in the same application through the use of subcommands. Each file the apps
module containing an execute()
method is considered a sub-command. The file name is used as the sub-command. In this example, note there are 2 example apps provided. example.py
and minimal_example.py
. Unless overridden, the subcommands would be example and minimal_example.
When muliple apps are specified, the subcommand is specified on the command line, before any app-specific command line options.
python src minimal_example
The subcommand name can be overridden by setting the following variables in the app *.py file:
SUBCOMMAND
- The string name of the subcommand. Used instead of the file name.ALIASES
- A list of strings which can be used as aliases for the subcommand.
Remember that subcommands only apply when multiple apps are found.
Build and activate the conda environment from the environment.yaml
mamba env create -f environment.yaml
mamba activate orekit-application
python src --help
Recreate the environment.yaml
as follows:
mamba env export --from-history | grep -vi '^prefix:' > environment.yaml