Skip to content

Add support to both .yml and .yaml#1501

Merged
minrk merged 5 commits intojupyterhub:mainfrom
rgaiacs:1373-yaml
Jan 23, 2026
Merged

Add support to both .yml and .yaml#1501
minrk merged 5 commits intojupyterhub:mainfrom
rgaiacs:1373-yaml

Conversation

@rgaiacs
Copy link
Contributor

@rgaiacs rgaiacs commented Jan 16, 2026

Closes #1373

@rgaiacs rgaiacs self-assigned this Jan 16, 2026
if not os.path.exists(environment_yml):
self._environment_yaml = {}
return self._environment_yaml
for filename in ["environment.yml", "environment.yaml"]:
Copy link
Member

Choose a reason for hiding this comment

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

These repetitions make me think perhaps we want a self.environment_yaml attribute or property that's resolved once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have a self.environment_yaml attribute

_environment_yaml = None
@property
def environment_yaml(self):
if self._environment_yaml is not None:
return self._environment_yaml
environment_yml = self.binder_path("environment.yml")
if not os.path.exists(environment_yml):
self._environment_yaml = {}
return self._environment_yaml
with open(environment_yml) as f:
env = YAML().load(f)
# check if the env file is empty, if so instantiate an empty dictionary.
if env is None:
env = {}
# check if the env file provided a dict-like thing not a list or other data structure.
if not isinstance(env, Mapping):
raise TypeError(
"environment.yml should contain a dictionary. Got %r" % type(env)
)
self._environment_yaml = env
return self._environment_yaml
but it does something else.

@rgaiacs rgaiacs requested a review from minrk January 22, 2026 11:53
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Jan 22, 2026

Refactoring required a fresh brain to accurately read the properties name. :-D

All tests are passing, including the small test added to check for this new feature.

This pull request is ready for review.

@minrk
Copy link
Member

minrk commented Jan 23, 2026

Looks great, thanks!

@minrk minrk merged commit 97eda49 into jupyterhub:main Jan 23, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo2docker ignores the python environment when the extension is yaml

2 participants