Skip to content

ENT-13808: Improve release history generation and download handling#51

Open
sarakthon wants to merge 2 commits intocfengine:mainfrom
sarakthon:generate-community-checksums
Open

ENT-13808: Improve release history generation and download handling#51
sarakthon wants to merge 2 commits intocfengine:mainfrom
sarakthon:generate-community-checksums

Conversation

@sarakthon
Copy link
Copy Markdown
Contributor

No description provided.

@cf-bottom
Copy link
Copy Markdown

Thanks for submitting a PR! Maybe @larsewi can review this?

Comment on lines +32 to +35
generate_release_history()

generate_git_tags_map()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You also need to remove it from the end, now it runs twice :)

Also, the commit message should mention why you're doing this. That's almost always more important than restating what you did unless it's really obvious.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You did the removal part in the wrong commit (2nd commit).

Comment on lines 108 to 112
stable_releases = get_stable_releases(release_data)

file_checksums_dict = build_release_history(stable_releases)

write_version_files(stable_releases, folder)

sorted_releases = sort_release_data(file_checksums_dict)

write_json(f"./{folder}/checksums.json", sorted_releases)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These formatting changes should not be in the same commit.

Comment on lines 99 to 100
def process_release_type(folder, download_func):
# Function for processing either community or enterprise releases
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function was here already, but looking at it, I wonder if it unnecessarily complex.

Why is it necessary to pass in a download function, instead of just a download URL?

# Downloading releases.json:
try:
releases_data = get_json(ENTERPRISE_RELEASES_URL)
return requests.get(ENTERPRISE_RELEASES_URL)
Copy link
Copy Markdown
Member

@olehermanse olehermanse Apr 10, 2026

Choose a reason for hiding this comment

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

Here you change the return type from json / dict to a requests response object. However, where you use this, you only use response.content, right? Maybe it's cleaner to just return .content? When I write functions that essentially wrap requests in various ways, I usually like to not "leak" the fact that it is requests.

Comment on lines +186 to +203
def save_to_file(path, content):
try:
with open(path, "wb") as f:
f.write(content)
print(f"Saved {path}")

except OSError:
raise CFBSExitError(f"Failed to write file {path}.")


def load_json_from_file(path):
# Open saved file and return as dict
try:
with open(path, "r", encoding="utf-8") as f:
return json.load(f)

except OSError:
raise CFBSExitError(f"Failed to read file {path}.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking we could make a function which does "everything" you need, without saving the data to file and then reading it from file again;

def json_get_save_return(url: str, path: str) -> dict:
    r = requests.get(url)
    content = r.content
    with open(path, "wb") as f:
        f.write(content)
    # TODO: Add some error handling
    data = json.loads(content)
    return data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants