From c99cd9602c45822e1c99d7a825ee0c8a6afcaf41 Mon Sep 17 00:00:00 2001 From: zietzm Date: Tue, 27 Aug 2024 16:40:56 -0700 Subject: [PATCH] feat: use permanent directory for outputs in development --- src/webgwas_backend/s3_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/webgwas_backend/s3_client.py b/src/webgwas_backend/s3_client.py index b7303fc..94fabd0 100644 --- a/src/webgwas_backend/s3_client.py +++ b/src/webgwas_backend/s3_client.py @@ -1,5 +1,5 @@ +import os import pathlib -import tempfile from abc import ABC, abstractmethod import boto3 @@ -34,15 +34,15 @@ def get_presigned_url(self, key): class S3MockClient(S3Client): def __init__(self, bucket: str = "webgwas"): - self.temp_dir = tempfile.TemporaryDirectory() - self.data_dir = pathlib.Path(self.temp_dir.name) + self.temp_dir = pathlib.Path(os.getcwd()).joinpath("temp_data") + self.temp_dir.mkdir(exist_ok=True) self.files = {} self.bucket = bucket def upload_file(self, local_path, key): - pathlib.Path(local_path).rename(self.data_dir / key) + pathlib.Path(local_path).rename(self.temp_dir / key) bucket_keys = self.files.setdefault(self.bucket, {}) - bucket_keys[key] = self.data_dir / key + bucket_keys[key] = self.temp_dir / key def get_presigned_url(self, key): return self.files[self.bucket][key].as_posix()