diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py index 4075437..11302ec 100644 --- a/cellxgene_gateway/gateway.py +++ b/cellxgene_gateway/gateway.py @@ -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 diff --git a/cellxgene_gateway/items/s3/s3item_source.py b/cellxgene_gateway/items/s3/s3item_source.py index aec9eca..60d3e2f 100644 --- a/cellxgene_gateway/items/s3/s3item_source.py +++ b/cellxgene_gateway/items/s3/s3item_source.py @@ -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):