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.
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 callget_target_file()
. This takes about 6 seconds to fail gracefully ontargets_modified
then another 6 seconds to fail ontargets
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()
.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()
.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.