Spaces:
Sleeping
Sleeping
Commit
Β·
3bc689a
1
Parent(s):
4f7f009
made few changes
Browse files- Dockerfile +3 -1
- app.py +11 -11
Dockerfile
CHANGED
|
@@ -8,7 +8,9 @@ RUN --mount=type=secret,id=CLEARML_API_ACCESS_KEY,required=true \
|
|
| 8 |
RUN useradd -m -u 1000 user
|
| 9 |
USER user
|
| 10 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
COPY --chown=user ./requirements.txt requirements.txt
|
|
|
|
| 8 |
RUN useradd -m -u 1000 user
|
| 9 |
USER user
|
| 10 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
+
ENV CLEARML_WEB_HOST="https://app.clear.ml/"
|
| 12 |
+
ENV CLEARML_API_HOST="https://api.clear.ml"
|
| 13 |
+
ENV CLEARML_FILES_HOST="https://files.clear.ml"
|
| 14 |
WORKDIR /app
|
| 15 |
|
| 16 |
COPY --chown=user ./requirements.txt requirements.txt
|
app.py
CHANGED
|
@@ -3,7 +3,7 @@ from fastapi.responses import HTMLResponse, RedirectResponse, JSONResponse
|
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from typing import List
|
| 5 |
import os # β add this
|
| 6 |
-
from clearml import Model
|
| 7 |
import torch
|
| 8 |
from configs import add_args
|
| 9 |
from models import build_or_load_gen_model
|
|
@@ -19,6 +19,15 @@ CLEARML_ACCESS_KEY = os.environ["CLEARML_API_ACCESS_KEY"]
|
|
| 19 |
CLEARML_SECRET_KEY = os.environ["CLEARML_API_SECRET_KEY"]
|
| 20 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
MAX_SOURCE_LENGTH = 512
|
| 23 |
|
| 24 |
def pad_assert(tokenizer, source_ids):
|
|
@@ -57,16 +66,7 @@ config, base_model, tokenizer = build_or_load_gen_model(args)
|
|
| 57 |
print("Base model architecture and tokenizer loaded.")
|
| 58 |
|
| 59 |
# Download the fine-tuned weights via ClearML using your injected creds
|
| 60 |
-
model_obj = Model(
|
| 61 |
-
model_id="34e25deb24c64b74b29c8519ed15fe3e",
|
| 62 |
-
api_host=CLEARML_API_SERVER,
|
| 63 |
-
web_host=CLEARML_WEB_SERVER,
|
| 64 |
-
files_host=CLEARML_FILES_SERVER,
|
| 65 |
-
credentials={
|
| 66 |
-
"access_key": CLEARML_ACCESS_KEY,
|
| 67 |
-
"secret_key": CLEARML_SECRET_KEY,
|
| 68 |
-
},
|
| 69 |
-
)
|
| 70 |
finetuned_weights_path = model_obj.get_local_copy()
|
| 71 |
adapter_dir = os.path.dirname(finetuned_weights_path)
|
| 72 |
print(f"Fine-tuned adapter weights downloaded to directory: {adapter_dir}")
|
|
|
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from typing import List
|
| 5 |
import os # β add this
|
| 6 |
+
from clearml import Model, Task
|
| 7 |
import torch
|
| 8 |
from configs import add_args
|
| 9 |
from models import build_or_load_gen_model
|
|
|
|
| 19 |
CLEARML_SECRET_KEY = os.environ["CLEARML_API_SECRET_KEY"]
|
| 20 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
|
| 22 |
+
# Configure ClearML SDK with injected environment variables
|
| 23 |
+
Task.set_credentials(
|
| 24 |
+
api_host=CLEARML_API_SERVER,
|
| 25 |
+
web_host=CLEARML_WEB_SERVER,
|
| 26 |
+
files_host=CLEARML_FILES_SERVER,
|
| 27 |
+
key=CLEARML_ACCESS_KEY,
|
| 28 |
+
secret=CLEARML_SECRET_KEY,
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
MAX_SOURCE_LENGTH = 512
|
| 32 |
|
| 33 |
def pad_assert(tokenizer, source_ids):
|
|
|
|
| 66 |
print("Base model architecture and tokenizer loaded.")
|
| 67 |
|
| 68 |
# Download the fine-tuned weights via ClearML using your injected creds
|
| 69 |
+
model_obj = Model(model_id="34e25deb24c64b74b29c8519ed15fe3e")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
finetuned_weights_path = model_obj.get_local_copy()
|
| 71 |
adapter_dir = os.path.dirname(finetuned_weights_path)
|
| 72 |
print(f"Fine-tuned adapter weights downloaded to directory: {adapter_dir}")
|