mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-27 09:28:12 +08:00
#59 add refresh query param to force refresh of S3 cache
This commit is contained in:
@@ -22,9 +22,7 @@ from flask import (
|
||||
send_from_directory,
|
||||
url_for,
|
||||
)
|
||||
from flask_api import status
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from cellxgene_gateway import env, flask_util
|
||||
from cellxgene_gateway.backend_cache import BackendCache
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
# the specific language governing permissions and limitations under the License.
|
||||
|
||||
from os.path import basename, dirname, join
|
||||
from os.path import basename, dirname
|
||||
from typing import List
|
||||
|
||||
import s3fs
|
||||
from flask import request
|
||||
|
||||
from cellxgene_gateway import dir_util
|
||||
from cellxgene_gateway.items.item import ItemTree, ItemType
|
||||
@@ -18,6 +19,10 @@ from cellxgene_gateway.items.item_source import ItemSource, LookupResult
|
||||
from cellxgene_gateway.items.s3.s3item import S3Item
|
||||
|
||||
|
||||
def truthy(val: str):
|
||||
return val.lower() in ["true", "1"]
|
||||
|
||||
|
||||
class S3ItemSource(ItemSource):
|
||||
def __init__(
|
||||
self,
|
||||
@@ -76,10 +81,10 @@ class S3ItemSource(ItemSource):
|
||||
|
||||
if not self.s3.exists(url):
|
||||
raise Exception(f"S3 url '{url}' does not exist.")
|
||||
|
||||
refresh = truthy(request.args.get("refresh", default="false")) or not self.use_listings_cache
|
||||
s3key_map = dict(
|
||||
(self.remove_bucket(filepath), "s3://" + filepath)
|
||||
for filepath in sorted(self.s3.ls(url, refresh=not self.use_listings_cache))
|
||||
for filepath in sorted(self.s3.ls(url, refresh=refresh))
|
||||
)
|
||||
|
||||
def is_annotation_dir(dir_s3key):
|
||||
|
||||
Reference in New Issue
Block a user