Skip to content

Commit 802a966

Browse files
Apply TR suggestions, add requirements file
Co-authored-by: Bartosz <[email protected]>
1 parent fbcd91f commit 802a966

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

openai-dalle/convert.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
from base64 import b64decode
33
from pathlib import Path
44

5-
JSON_FILE_NAME = "An ec-1667994848"
6-
IMAGE_DIR = Path.cwd() / "images" / JSON_FILE_NAME
5+
JSON_FILE = Path("An ec-1668602437.json")
6+
IMAGE_DIR = Path.cwd() / "images" / JSON_FILE.stem
77
DATA_DIR = Path.cwd() / "responses"
88

99
IMAGE_DIR.mkdir(parents=True, exist_ok=True)
1010

11-
with open(DATA_DIR / f"{JSON_FILE_NAME}.json", "r") as f:
12-
response = json.load(f)
11+
with open(DATA_DIR / JSON_FILE, "r") as file:
12+
response = json.load(file)
1313

1414
for index, image_dict in enumerate(response["data"]):
1515
image_data = b64decode(image_dict["b64_json"])
16-
with open(IMAGE_DIR / f"{JSON_FILE_NAME}-{index}.png", "wb") as f:
17-
f.write(image_data)
16+
with open(IMAGE_DIR / f"{JSON_FILE.stem}-{index}.png", "wb") as png_file:
17+
png_file.write(image_data)

openai-dalle/create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020

2121
file_name = DATA_DIR / f"{PROMPT[:5]}-{response['created']}.json"
2222

23-
with open(file_name, mode="w") as file_path:
24-
json.dump(response, file_path)
23+
with open(file_name, mode="w", encoding="utf-8") as file:
24+
json.dump(response, file)

openai-dalle/edit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
with open(
2626
DESTINATION_PATH / f"edit-{PROMPT[:5]}-{response['created']}.json",
2727
mode="w",
28-
) as fp:
29-
json.dump(response, fp)
28+
encoding="utf-8",
29+
) as file:
30+
json.dump(response, file)

openai-dalle/requirements.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
certifi==2022.9.24
2+
charset-normalizer==2.1.1
3+
et-xmlfile==1.1.0
4+
idna==3.4
5+
numpy==1.23.4
6+
openai==0.25.0
7+
openpyxl==3.0.10
8+
pandas==1.5.1
9+
pandas-stubs==1.2.0.62
10+
python-dateutil==2.8.2
11+
pytz==2022.6
12+
requests==2.28.1
13+
six==1.16.0
14+
tqdm==4.64.1
15+
typing_extensions==4.4.0
16+
urllib3==1.26.12

openai-dalle/vary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323

2424
new_file_name = f"vary-{SOURCE_FILE[:4]}-{response['created']}.json"
2525

26-
with open(DATA_DIR / new_file_name, mode="w") as new_json_file:
27-
json.dump(response, new_json_file)
26+
with open(DATA_DIR / new_file_name, mode="w", encoding="utf-8") as file:
27+
json.dump(response, file)

0 commit comments

Comments
 (0)