|
10 | 10 | notification, |
11 | 11 | organization, |
12 | 12 | ) |
| 13 | +import pickle |
13 | 14 | import torch |
14 | 15 | import traceback |
15 | 16 | from requests.exceptions import HTTPError |
@@ -449,6 +450,16 @@ def run_encoding( |
449 | 450 | request_util.post_embedding_to_neural_search( |
450 | 451 | request.project_id, embedding_id |
451 | 452 | ) |
| 453 | + |
| 454 | + if get_config_value("is_managed"): |
| 455 | + pickle_path = os.path.join( |
| 456 | + "/inference", request.project_id, f"embedder-{embedding_id}.pkl" |
| 457 | + ) |
| 458 | + if not os.path.exists(pickle_path): |
| 459 | + os.makedirs(os.path.dirname(pickle_path), exist_ok=True) |
| 460 | + with open(pickle_path, "wb") as f: |
| 461 | + pickle.dump(embedder, f) |
| 462 | + |
452 | 463 | upload_embedding_as_file(request.project_id, embedding_id) |
453 | 464 | embedding.update_embedding_state_finished( |
454 | 465 | request.project_id, |
@@ -485,6 +496,9 @@ def delete_embedding(project_id: str, embedding_id: str) -> int: |
485 | 496 | org_id = organization.get_id_by_project_id(project_id) |
486 | 497 | s3.delete_object(org_id, project_id + "/" + object_name) |
487 | 498 | request_util.delete_embedding_from_neural_search(embedding_id) |
| 499 | + pickle_path = os.path.join("/inference", project_id, f"embedder-{embedding_id}.pkl") |
| 500 | + if os.path.exists(pickle_path): |
| 501 | + os.remove(pickle_path) |
488 | 502 | return 200 |
489 | 503 |
|
490 | 504 |
|
|
0 commit comments