Skip to content

Commit

Permalink
feat: use permanent directory for outputs in development
Browse files Browse the repository at this point in the history
  • Loading branch information
zietzm committed Aug 27, 2024
1 parent 6da4985 commit c99cd96
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/webgwas_backend/s3_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import pathlib
import tempfile
from abc import ABC, abstractmethod

import boto3
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c99cd96

Please sign in to comment.