Skip to content

Commit

Permalink
fix: only consider specified packages when stopping because of downgr…
Browse files Browse the repository at this point in the history
…ading (#65)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Improved error messaging when package downgrades are detected during
environment updates.
- Enhanced logic for identifying downgraded packages to ensure accuracy.

- **Chores**
- Refined internal processes for managing package dependencies without
altering public interfaces.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
johanneskoester authored Oct 9, 2024
1 parent d33541a commit 2aa3f82
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions snakedeploy/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import re
from glob import glob
from itertools import chain
import github
from urllib3.util.retry import Retry
import random

Expand Down Expand Up @@ -222,7 +223,7 @@ def downgraded():
if prior_version is not None and version < VersionOrder(prior_version):
yield pkg_name

downgraded = list(downgraded())
downgraded = set(unconstrained_deps) & set(downgraded())
if downgraded:
msg = (
f"Env {conda_env_path} could not be updated because the following packages "
Expand Down Expand Up @@ -338,19 +339,24 @@ def create(self):
ref=f"refs/heads/{self.branch}",
sha=self.repo.get_branch(self.base_ref).commit.sha,
)
breakpoint()
for file in self.files:
if file.is_updated:
sha = None
if branch_exists:
logger.info(
f"Obtaining sha of {file.path} on branch {self.branch}..."
)
sha = None
if branch_exists:
logger.info(f"Obtaining sha of {file.path} on branch {self.branch}...")
try:
# try to get sha if file exists
sha = self.repo.get_contents(file.path, self.branch).sha
else:
logger.info(
f"Obtaining sha of {file.path} on branch {self.base_ref}..."
)
sha = self.repo.get_contents(file.path, self.base_ref).sha
except github.GithubException.UnknownObjectException as e:
if e.status != 404:
raise e
elif file.is_updated:
logger.info(
f"Obtaining sha of {file.path} on branch {self.base_ref}..."
)
sha = self.repo.get_contents(file.path, self.base_ref).sha

if sha is not None:
self.repo.update_file(
file.path,
file.msg,
Expand All @@ -362,6 +368,7 @@ def create(self):
self.repo.create_file(
file.path, file.msg, file.content, branch=self.branch
)

pr_exists = any(
pr.head.label.split(":", 1)[1] == self.branch
for pr in self.repo.get_pulls(state="open", base=self.base_ref)
Expand Down

0 comments on commit 2aa3f82

Please sign in to comment.