Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.py #19

Open
wants to merge 1 commit into
base: old_main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions promptify/models/nlp/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def download(url, destination_file):
os.makedirs(path)

destination_file = os.path.join(path, destination_file)

last_modified = ""
if os.path.exists(destination_file):
mtime = os.path.getmtime(destination_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't last_modified be named mtime? That way it's by default empty (on line 18), and becomes reassigned to the local file's last modified time (on line 20).

As it's written now, last_modified always equals "" on line 34, so the if statement does nothing.

headers["if-modified-since"] = formatdate(mtime, usegmt=True)
Expand All @@ -31,7 +31,7 @@ def download(url, destination_file):
for chunk in response.iter_content(chunk_size=1048576):
f.write(chunk)

if last_modified := response.headers.get("last-modified"):
if last_modified == response.headers.get("last-modified"):
new_mtime = parsedate_to_datetime(last_modified).timestamp()
os.utime(destination_file, times=(datetime.now().timestamp(), new_mtime))
return destination_file