Skip to content

Virtualship package restructure and defining the Python public API #176

@VeckoTheGecko

Description

@VeckoTheGecko

The package structure currently looks like this:

src
└── virtualship
    ├── __init__.py
    ├── _version_setup.py
    ├── cli
    │   ├── __init__.py
    │   ├── _creds.py
    │   ├── _fetch.py
    │   ├── commands.py
    │   └── main.py
    ├── expedition
    │   ├── __init__.py
    │   ├── checkpoint.py
    │   ├── do_expedition.py
    │   ├── expedition_cost.py
    │   ├── input_data.py
    │   ├── instrument_type.py
    │   ├── schedule.py
    │   ├── ship_config.py
    │   ├── simulate_measurements.py
    │   ├── simulate_schedule.py
    │   ├── space_time_region.py
    │   └── waypoint.py
    ├── instruments
    │   ├── __init__.py
    │   ├── adcp.py
    │   ├── argo_float.py
    │   ├── ctd.py
    │   ├── drifter.py
    │   ├── ship_underwater_st.py
    │   └── xbt.py
    ├── location.py
    ├── make_realistic
    │   ├── __init__.py
    │   ├── adcp_make_realistic.py
    │   └── ctd_make_realistic.py
    ├── spacetime.py
    ├── static
    │   ├── __init__.py
    │   ├── schedule.yaml
    │   └── ship_config.yaml
    └── utils.py

7 directories, 35 files

The cli code is siloed off (which is great), but the rest of the code could be structured better:

  • configuration objects are all living in the expedition package. This makes it difficult to locate the configuration classes compared to the code that contains the logic. The config subcomponents which build into the ShipConfig, for example, are split across multiple files making it difficult to see that indeed they belong to the ShipConfig object.
  • The __init__.py files do a lot of imports, which increases the likelihood of running into circular import issues.
  • a lot of separate files (almost one per class) which is not necessary, and instead we could group them by functionality into themed modules

Defining the Python public API

From a user POV, are there any cases where users will run VirtualShip via Python itself (e.g., import virtualship; virtualship.do_expedition(....))?

Since the main goal of VirtualShip is education, I would opt for making the public API for the project being the CLI and have the Python part of things be internal. I think this reflects the current development, provides clear expectations to users, and gives developers the flexibility to make changes. If users want to run VirtualShip programmatically they can use Python to run command line commands.

Keen to know your thoughts and plans for future development.

cc @erikvansebille @ammedd @iuryt @j-atkins let me know if you have opinions on the public API

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions