Skip to content

Write the modified conda env to a temporary file #8585

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

Closed
wants to merge 3 commits into from

Conversation

Cadair
Copy link

@Cadair Cadair commented Oct 14, 2021

This is a stab in the dark at fixing #8201

It attempts to save the conda env file to a location outside of the checkout so that it doesn't interfere with the checkout / version number.

@@ -767,16 +773,16 @@ def _append_core_requirements(self):
dependencies.append(pip_dependencies)
dependencies.extend(conda_requirements)
environment.update({'dependencies': dependencies})
_, output_filename = tempfile.mkstemp(dir=Path(self.checkout_path) / ".." / "..", suffix=".yml")
Copy link
Author

Choose a reason for hiding this comment

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

The main issue I had was working out what the correct base path for this tempfile should be. I tried /tmp but then the shell commands couldn't find the file, this was the only compromise I could get to work. I am sure someone can tell me a better answer.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is because this code is executed in the host, and then the file is read from inside the container. So, the only way to share a file between them is by using a path under the one that is mounted from the host into the container (self.checkout_path)

@astrojuanlu
Copy link
Contributor

Thanks @Cadair for trying to get to this point.

@humitos @ericholscher This is very clearly a dirty hack, but I wonder if we can get it to a point where it's mergeable, or if we should find a totally different strategy? @Cadair shared with me some logs in private while working on the issue and it was like some directories were wiped between steps, or something like that. I didn't have enough knowledge about our build process to give better recommendations.

@humitos
Copy link
Member

humitos commented Oct 18, 2021

Hi all! I think the idea makes sense: use a temporal file outside the git checkout to avoid having a dirty state. However, we do modify other files as well (like conf.py) and we should take a look at them also.

Regarding the implementation itself, we should double-check where else self.config.conda.environment is used and change those for the new location. It may make sense to make self.config.conda.environment to return the temporal file instead, tho.

Finally, what happened with the suggestion from this comment #8201 (comment). Have you tried it?

I think a good solution is having setuptools_scm ignore the edited files and always use the no distance and clean or distance and clean forms pypa/setuptools_scm#default-versioning-scheme

@Cadair
Copy link
Author

Cadair commented Oct 19, 2021

Hi all! I think the idea makes sense: use a temporal file outside the git checkout to avoid having a dirty state. However, we do modify other files as well (like conf.py) and we should take a look at them also.

The specific issue with this one is that it is modified before the package is installed. Things like modifying the conf.py don't have the same issue with setuptools_scm because the package has already been installed so the version number has been calculated.

[...] Have you tried it?

Yes, we hacked various things together, it's possible but really ugly if you want to keep development version numbers for the "latest" builds.

@adrien-berchet
Copy link

Hello there,
I proposed something simpler to @Cadair (with a PR on this PR) but I am not sure he saw the notification: Cadair#1
I can open a new PR here if you prefer.
Anyway, feel free to comment it, it would be nice to solve this issue :)

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Mar 2, 2022
@humitos
Copy link
Member

humitos commented Mar 2, 2022

Thanks for opening this PR. We are implementing pre/post commands in our builders. Once that is done, this issue can be solved with the git command described at #8201 (comment)

I'm closing this PR because I don't think we will include a solution like this in the core application. We can come back to this and re-open if we feel it. Thanks!

@humitos humitos closed this Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: stale Issue will be considered inactive soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants