BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 129 forks source link

Extend target file API to list and/or check existence of objects #1752

Open mark-toma-at-ball opened 2 years ago

mark-toma-at-ball commented 2 years ago

I would like to check for existence of target files before attempting to get_target_file().

Is your feature request related to a problem? Please describe. I'm currently using the exception thrown by Cosmos::Script::_get_presigned_url() to assume a file doesn't exist when I call get_target_file(). This takes about 6 seconds to fail gracefully on targets_modified then another 6 seconds to fail on targets when the file doesn't exist. Twelve seconds is a long time to wait to check for nonexistent objects.

Describe the solution you'd like My immediate need is to check existence of a target file with a new API exists_target_file().

object_name = 'PLUGIN/data/path/to/my_file.ext' # target file to check
if exists_target_file(object_name) 
  get_target_file(object_name) # get target file if exists
end

While thinking about implementation (e.g. MinIO list_objects with prefix) and possibility to do multiple checks with a single higher level API call, that evolved into this concept for list_target_files().

object_name = 'my_file.ext' # target file to check
object_prefix = 'PLUGIN/data/path/to/' # target folder to look in
object_list = list_target_files(object_prefix)
if object_list.include?(object_name) # Note: specific check subject to format/contents of object_list
  get_target_file("#{object_prefix}#{object_name}") # get target file if exists
end

The former could be a specialization of the latter so I would request list_target_files() with higher priority.

Additional context

My main goal is to adapt existing code to read configs and write output files while remaining robust to file name/location flexibility. If there's a way to access files on the local machine (e.g. C:\path\to\configs-and-outputs\ on Windows) that would also be useful as a workaround.

jmthomas commented 2 years ago

Fixed in OpenC3 v5.0.6