<div dir="ltr">Thanks Even,<div><br></div><div>Disabling reading the directory is another work around for my use case as well:</div><div>(GDAL_DISABLE_READDIR_ON_OPEN=TRUE)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 21, 2017 at 5:02 AM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div style="font-family:'Sans Serif';font-size:9pt;font-weight:400;font-style:normal">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Matt,</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> My actual problem is a bit more specific then being unable to open S3 files</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> after upload. The actual problem is that within the same Python session, I</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> can open a file off S3 with the vsis3 driver, but then if I upload a new</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> file that previously did not exist (using boto3), gdal does not see it as a</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> valid file. </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Yes I'm aware of that issue. There's indeed metadata (file size & date, directory listing) and data (chunks of files) cached by /vsicurl/ and related file systems like /vsis3/ . /vsicurl/ was designed at a time where web resources didn't change that much and it was unlikely during a same GDAL session to see changes, but with cloud offerings, this is no longer the case.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">A few weeks ago I've added in trunk a CPL_VSIL_CURL_NON_CACHED config option that can be set to disable caching on a file or set of files.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">See <a href="https://trac.osgeo.org/gdal/wiki/ConfigOptions#CPL_VSIL_CURL_NON_CACHED" target="_blank">https://trac.osgeo.org/gdal/<wbr>wiki/ConfigOptions#CPL_VSIL_<wbr>CURL_NON_CACHED</a></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">So in your example, if you set</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">CPL_VSIL_CURL_NON_CACHED=/<wbr>vsis3/put_here_the_bucket_name , that will work.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">I've also just added per <a href="https://trac.osgeo.org/gdal/ticket/6937" target="_blank">https://trac.osgeo.org/gdal/<wbr>ticket/6937</a> a new function VSICurlClearCache() function (bound to SWIG as gdal.VSICurlClearCache()). So if you add gdal.VSICurlClearCache() just after the s3.meta.client.upload_file() call, that will work too.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Both mechanisms are complementary.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">CPL_VSIL_CURL_NON_CACHED is useful in scenarios where you don't know when the server content can change (some other processes or machines do that behind your back). Its advantage is that it doesn't require modification of code (it was designed for MapServer use case typically). The drawback of it is that you loose all caching when a same file is opened, close, opened, closed, ... several times during the process.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">VSICurlClearCache() will give you more control if you master when uploads happen.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">I've also backported VSICurlClearCache() to 2.2 branch.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">As far as VSI_CACHE=TRUE is concerned, its scope of caching is restricted to a same VSI file handle instance. Can be useful if the global 16 MB vsicurl cache isn't big enough for very large files.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Even</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">-- </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></div></blockquote></div><br></div>