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

Simplify git cloning #38

Merged
merged 5 commits into from
Jul 26, 2018
Merged

Simplify git cloning #38

merged 5 commits into from
Jul 26, 2018

Conversation

jeanconn
Copy link
Contributor

@jeanconn jeanconn commented Jul 24, 2018

This PR removes the logic that tries to git clone packages using ssh by default, and instead just explicitly uses whatever string is after "home:" in the meta.yaml. For private packages, that is now set to the github ssh string. For the rest, it is set to the https url.

Closes #8 (via explicit compromise on https and ssh urls)

jeanconn added 2 commits July 24, 2018 08:40
This commit replaces the https url for the private packages with github ssh and
changes the logic in ska_builder.py to just use whatever is in that url
(instead of guessing a github ssh string from the package name).
repo = git.Repo.clone_from(url, clone_path)
print("Cloned from url {}".format(url))
metayml = os.path.join(pkg_defs_path, name, "meta.yaml")
# It isn't clean yaml at this point, so just extract the string we want after "home:"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the previous requires/path loop was dealing with the fact that the meta.yaml isn't compliant YAML at this point at the path key. I just went with a regex here to grab the string after home: instead of trying to use the YAML parser. I think that is fair for our application.

Copy link
Member

Choose a reason for hiding this comment

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

I suspect it could be made into compliant YAML by enclosing the {{ .. }}/.. stuff in double quotes, but I agree with your point to just get the job done here.

failures.append(pkg_name)
continue
if len(failures):
raise ValueError("Packages {} failed".format(",".join(failures)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't strictly required, but I thought it might be helpful to let the build process continue through the rest of the packages even if you have an issue with one package (an issue such as forgetting your ssh key password) and then printing out the failures and exiting with error status at the end.

Copy link
Member

Choose a reason for hiding this comment

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

I sort of think that if something fails, there is really a problem that needs to be fixed before moving on (and maybe you can into dependency hell where every build starts failing because of the missing failed build). Since it doesn't re-build everything every time (right?), it seems pretty cheap to restart. The "forgetting ssh key" seems a not-credible failure.

repo = git.Repo.clone_from(url, clone_path)
print("Cloned from url {}".format(url))
metayml = os.path.join(pkg_defs_path, name, "meta.yaml")
# It isn't clean yaml at this point, so just extract the string we want after "home:"
Copy link
Member

Choose a reason for hiding this comment

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

I suspect it could be made into compliant YAML by enclosing the {{ .. }}/.. stuff in double quotes, but I agree with your point to just get the job done here.

metayml = os.path.join(pkg_defs_path, name, "meta.yaml")
# It isn't clean yaml at this point, so just extract the string we want after "home:"
meta = open(metayml).read()
url = re.search("home:\s?(\S+)", meta).group(1)
Copy link
Member

Choose a reason for hiding this comment

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

Should be \s*. Multiple spaces are fine. I can't remember if zero spaces is OK for YAML, but for this purpose yes.

failures.append(pkg_name)
continue
if len(failures):
raise ValueError("Packages {} failed".format(",".join(failures)))
Copy link
Member

Choose a reason for hiding this comment

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

I sort of think that if something fails, there is really a problem that needs to be fixed before moving on (and maybe you can into dependency hell where every build starts failing because of the missing failed build). Since it doesn't re-build everything every time (right?), it seems pretty cheap to restart. The "forgetting ssh key" seems a not-credible failure.

clone_path = os.path.join(self.src_dir, name)
if not os.path.exists(clone_path):
# Try ssh first to avoid needing passwords for the private repos
Copy link
Member

Choose a reason for hiding this comment

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

Awesome!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding continuing, my thought was that there could be other reasons for failure that you might not care about if all you really wanted to do was update a couple of packages at the end of the list. Or if you were a non-privileged user who'd just been handed this code base (JWST?) and this logic lets you really just see how everything works without stopping at parse_cm. You could get in to dependency hell in a fresh build with no access to the currently build packages in ska3-conda, but the only fallout of this change in that case would just be that it would take a lot longer to finish failing out with the rest of the packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, "forgetting ssh key password" was a creditable failure in my testing.

Copy link
Member

Choose a reason for hiding this comment

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

OK, well then put in a text input to ask the user to continue ala install.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@jeanconn
Copy link
Contributor Author

Is this good to go @taldcroft ?

@jeanconn jeanconn merged commit e8939e2 into master Jul 26, 2018
@jeanconn jeanconn deleted the fetching branch July 26, 2018 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants