Skip to content

Catch invalid schedule.yaml files #144

@erikvansebille

Description

@erikvansebille

Some students end up with a schedule.yaml file that looks like below

space_time_region:
  spatial_range:
    minimum_longitude: -5
    maximum_longitude: 5
    minimum_latitude: -5
    maximum_latitude: 5
    minimum_depth: 0
    maximum_depth: 2000
  time_range:
    start_time: 2023-01-01 00:00:00
    end_time: 2023-01-10 00:00:00
waypoints:
  - instrument:  # Should be -instrument: XBT
    - XBT
    location:
      latitude: 0.03
      longitude: 0.03
    time: 2023-01-01 03:00:00

This throws an error

  File "/Users/erik/Codes/virtualship/src/virtualship/expedition/do_expedition.py", line 37, in do_expedition
    waypoint.instrument.name
AttributeError: 'list' object has no attribute 'name'

Is there a way to validate the schedule.yaml file immediately after/when the schedule is loaded?
https://github.com/OceanParcels/virtualship/blob/e71d1d9bd33e9607b64fae9e43eedb23286be88a/src/virtualship/expedition/do_expedition.py#L33

And then catch these invalid schedules with a more informative error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions