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

[ENT-12098] Add an initial implementation of an internal cfbs command to generate MPF release information #208

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jakub-nt
Copy link
Contributor

No description provided.

@cf-bottom
Copy link

Thank you for submitting a PR! Maybe @craigcomstock can review this?

Copy link
Member

@olehermanse olehermanse left a comment

Choose a reason for hiding this comment

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

Looks good so far, some preliminary comments.

masterfiles/analyze.py Outdated Show resolved Hide resolved
cfbs/utils.py Show resolved Hide resolved
cfbs/commands.py Outdated Show resolved Hide resolved
masterfiles/check_download_matches_git.py Outdated Show resolved Hide resolved
Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

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

Cool. Noticed a few things with a cursory look. I didn't check the logic too carefully. I can make another pass if need be.

cfbs/masterfiles/analyze.py Outdated Show resolved Hide resolved
cfbs/masterfiles/analyze.py Outdated Show resolved Hide resolved
cfbs/masterfiles/generate_vcf_git_checkout.py Outdated Show resolved Hide resolved
cfbs/masterfiles/generate_vcf_git_checkout.py Show resolved Hide resolved
Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

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

Nice.

Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

Great work 🚀 I see you still have some # TODO's left to address. I have some smaller nitpicks for you. But in general:

  • It's nice if you try to avoid too many nested if's. They tend to make it really hard to understand the code. But this is not always the case.
  • When you look for the masterfiles tarball URL, maybe it's possible to search for it, instead of hard coding where it is in the JSON? Maybe there is a common denominator you can look for? I'm not sure.

I tried running your program, but it hung. Or maybe it just takes a very long time? I did not try to figure out why.

Looking forward to re-review!

def versions_checksums_files(
files_dir_path, version, versions_dict, checksums_dict, files_dict
):
for root, dirs, files in os.walk(files_dir_path):
Copy link
Contributor

Choose a reason for hiding this comment

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

Best practice is to use _ when we don't care about the value

Suggested change
for root, dirs, files in os.walk(files_dir_path):
for root, _, files in os.walk(files_dir_path):

"""

import os
import dictdiffer
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider avoiding this dependency. Otherwise we should add it to requirements.txt ?

git_version_dict = git_versions_dict["versions"][version]["files"]

for diff in list(dictdiffer.diff(download_version_dict, git_version_dict)):
with open("differences/difference-" + version + ".txt", "w") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can open the files once (per version in versions) instead of opening them every time you want to append a line?

does_match = True

for version in downloaded_versions:
print(version)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a leftover debugging print?


filename = url.split("/")[-1]
tarball_path = version_path / filename
urllib.request.urlretrieve(url, tarball_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using fetch_url() from cfbs.utils. Otherwise, make sure to check status code

Comment on lines +20 to +28
def check_required_command(command):
if not shutil.which(command):
print("`%s` was not found" % command)
sys.exit(1)


def check_required_commands(commands):
for c in commands:
check_required_command(c)
Copy link
Contributor

Choose a reason for hiding this comment

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

These two can probably be the same function. If the passed argument is an interable, then it can recursively call itself for each element in the iterable.

required_commands = ["git", "make", "automake", "autoconf"]
check_required_commands(required_commands)

# clone the MPF repo every time the script is run, in case there are updates
Copy link
Contributor

@larsewi larsewi Nov 6, 2024

Choose a reason for hiding this comment

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

Can you not fetch and rebase instead?

if os.path.isdir(MPF_PATH):
shutil.rmtree(MPF_PATH)

subprocess.run(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should handle exceptions if the command fails? I'm not sure.

versions_dict, checksums_dict, files_dict = initialize_vcf()

for tag in interesting_tags:
print(tag)
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover debug print?

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.

5 participants