Skip to content

Log conda version and docker image hash when creating a container. #8755

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
16 changes: 16 additions & 0 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,20 @@ def container_id(self):
if self.container:
return self.container.get('Id')

@property
def conda_version(self):
"""Return conda version if exists."""
try:
version = subprocess.run(
["conda", "--version"],
capture_output=True,
text=True,
check=True,
)
Copy link
Member

Choose a reason for hiding this comment

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

We are using Docker in our build process, so this command won't work. We need to execute the conda --version inside the Docker container where the build is taking place. I remember there are other places in the code where we execute a command to get the Sphinx's version (I think) from where you can copy the idea to get the conda's version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comment @humitos. I am dealing with my finals now. Would that be okay if a take a look at it in the next week?

Copy link
Member

Choose a reason for hiding this comment

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

Yes! 👍🏼

return version.stdout
except Exception:
return "conda environment is not set"

def container_state(self):
"""Get container state."""
client = self.get_client()
Expand Down Expand Up @@ -1020,6 +1034,8 @@ def create_container(self):
'Creating Docker container.',
container_image=self.container_image,
container_id=self.container_id,
conda_version=self.conda_version,
image_hash=self.image_hash,
)
self.container = client.create_container(
image=self.container_image,
Expand Down