VisionSystemsInc / terra

Terra - Run your algorithm anywhere on earth
MIT License
0 stars 3 forks source link

pathlib for volume_map translation #56

Closed drewgilliam closed 4 years ago

drewgilliam commented 4 years ago

Use pathlib for compute.utils.translate_settings_paths for all flavors of container_platform. Additionally break path translation steps into separate functions for more unit tests.

This addresses a bug where a user has the following setup, where the output directory starts with the same string as the input directory (though output and input are separate folders). This is a valid configuration and should be handled.

Consider the following configuration:

{
  "image_dir": "/path/to/data",
  "service_dir": "/path/to/data_output/service",
}

And the following volume_map:

[
  ["/path/to/data_output/service", "/dem/service"],
  ["/path/to/data", "/dem/images"]
]

A volume_map using string comparison produces the following incorrect translation. Note volume_map tuples are applied in reverse order to each configuration option until a match is found.

{
  "image_dir": "/dem/images",
  "service_dir": "/dem/images_output/service",  # "/path/to/data_output/service".startswith("path/to/data")
}

Using pathlib comparison, volume mappings match to directories/files only & produce the expected translation:

{
  "image_dir": "/dem/images",
  "service_dir": "/dem/service",
}