Spaces:
Running
Running
Robert commited on
Commit ·
b733a1f
1
Parent(s): e87bceb
Show logs
Browse files- Dockerfile +1 -0
- test_compress.py +38 -8
Dockerfile
CHANGED
|
@@ -51,6 +51,7 @@ ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface
|
|
| 51 |
ENV XDG_CACHE_HOME=/tmp/.cache
|
| 52 |
ENV GRADIO_CACHE_DIR=/tmp/.gradio
|
| 53 |
ENV GRADIO_EXAMPLES_CACHE=/tmp/.gradio/cached_examples
|
|
|
|
| 54 |
|
| 55 |
RUN mkdir -p /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio /tmp/.gradio/cached_examples \
|
| 56 |
&& chmod -R 777 /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio /tmp/.gradio/cached_examples
|
|
|
|
| 51 |
ENV XDG_CACHE_HOME=/tmp/.cache
|
| 52 |
ENV GRADIO_CACHE_DIR=/tmp/.gradio
|
| 53 |
ENV GRADIO_EXAMPLES_CACHE=/tmp/.gradio/cached_examples
|
| 54 |
+
ENV PYTHONUNBUFFERED=1
|
| 55 |
|
| 56 |
RUN mkdir -p /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio /tmp/.gradio/cached_examples \
|
| 57 |
&& chmod -R 777 /tmp/model /tmp/huggingface /tmp/.cache /tmp/.gradio /tmp/.gradio/cached_examples
|
test_compress.py
CHANGED
|
@@ -143,7 +143,19 @@ def _digest_exists_remotely(digest: str) -> bool:
|
|
| 143 |
return True
|
| 144 |
except ClientError as exc:
|
| 145 |
code = exc.response.get("Error", {}).get("Code")
|
| 146 |
-
if code in {"404", "NoSuchKey"}:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
return False
|
| 148 |
raise
|
| 149 |
|
|
@@ -151,13 +163,30 @@ def _digest_exists_remotely(digest: str) -> bool:
|
|
| 151 |
def _store_digest_marker(digest: str, metadata: dict[str, str]) -> None:
|
| 152 |
if not s3 or not BUCKET_NAME:
|
| 153 |
return
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
|
| 163 |
def _prune(now: datetime.datetime) -> None:
|
|
@@ -374,6 +403,7 @@ def imagine(local_path: str, age: int, *, context: UploadContext | None = None)
|
|
| 374 |
|
| 375 |
prepared_upload: PreparedUpload | None = None
|
| 376 |
if not s3 or not BUCKET_NAME:
|
|
|
|
| 377 |
return None
|
| 378 |
try:
|
| 379 |
prepared_upload = _prepare_upload(local_path)
|
|
|
|
| 143 |
return True
|
| 144 |
except ClientError as exc:
|
| 145 |
code = exc.response.get("Error", {}).get("Code")
|
| 146 |
+
if code in {"404", "NoSuchKey", "403", "Forbidden"}:
|
| 147 |
+
if code in {"403", "Forbidden"}:
|
| 148 |
+
print(
|
| 149 |
+
json.dumps(
|
| 150 |
+
{
|
| 151 |
+
"event": "dedupe_head_forbidden",
|
| 152 |
+
"digest": digest[:12],
|
| 153 |
+
"issue": "head_object_forbidden",
|
| 154 |
+
},
|
| 155 |
+
ensure_ascii=True,
|
| 156 |
+
sort_keys=True,
|
| 157 |
+
)
|
| 158 |
+
)
|
| 159 |
return False
|
| 160 |
raise
|
| 161 |
|
|
|
|
| 163 |
def _store_digest_marker(digest: str, metadata: dict[str, str]) -> None:
|
| 164 |
if not s3 or not BUCKET_NAME:
|
| 165 |
return
|
| 166 |
+
try:
|
| 167 |
+
s3.put_object(
|
| 168 |
+
Bucket=BUCKET_NAME,
|
| 169 |
+
Key=_digest_marker_key(digest),
|
| 170 |
+
Body=b"",
|
| 171 |
+
ContentType="text/plain",
|
| 172 |
+
Metadata=metadata,
|
| 173 |
+
)
|
| 174 |
+
except ClientError as exc:
|
| 175 |
+
code = exc.response.get("Error", {}).get("Code")
|
| 176 |
+
if code in {"403", "Forbidden"}:
|
| 177 |
+
print(
|
| 178 |
+
json.dumps(
|
| 179 |
+
{
|
| 180 |
+
"event": "dedupe_marker_forbidden",
|
| 181 |
+
"digest": digest[:12],
|
| 182 |
+
"issue": "put_object_forbidden",
|
| 183 |
+
},
|
| 184 |
+
ensure_ascii=True,
|
| 185 |
+
sort_keys=True,
|
| 186 |
+
)
|
| 187 |
+
)
|
| 188 |
+
return
|
| 189 |
+
raise
|
| 190 |
|
| 191 |
|
| 192 |
def _prune(now: datetime.datetime) -> None:
|
|
|
|
| 403 |
|
| 404 |
prepared_upload: PreparedUpload | None = None
|
| 405 |
if not s3 or not BUCKET_NAME:
|
| 406 |
+
print()
|
| 407 |
return None
|
| 408 |
try:
|
| 409 |
prepared_upload = _prepare_upload(local_path)
|