Skip to content

reverse generated-python direction #1459

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

Merged
merged 2 commits into from
Mar 29, 2022

Conversation

minrk
Copy link
Member

@minrk minrk commented Mar 8, 2022

Make binderspawner_mixin.py canonical, instead of python-in-yaml

easier to edit with editors, linters, etc.

removes use of redundant pyyaml in favor of ruamel.yaml, needed for roundtrip yaml editing

@minrk minrk force-pushed the reverse-generated-spawner branch from b2a96b3 to 07c87f5 Compare March 8, 2022 10:07
Copy link
Member

@manics manics left a comment

Choose a reason for hiding this comment

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

This duplication is something that annoys me too 😞 . Good to merge once the tests are passing.

In future we could probably add this to pre-commit so the scripts gets updated automatically as part of linting.

@@ -17,7 +17,7 @@ nodeSelector: {}

image:
name: jupyterhub/k8s-binderhub
tag: 'local'
tag: local
Copy link
Member

Choose a reason for hiding this comment

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

If you use a round trip, the quotes may not be left for a string that needs them i think.

Retainig explicit quotes for the tag has been relevant in the past i recall, perhaps not by chartpress generates image tags, but i'm still cautious preferring to see us having the yaml include quotes foe our placeholder values where they could be needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

The quotes were removed by the roundtrip serialization. I did not remove them. I left the change here because every re-write of the file will strip it.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is how we have configured ruamel.yaml in chartpress to avoid this kind of issue.

# use safe roundtrip yaml loader capable or preserving usage of no/single/double
# quotes for a string for example
yaml = YAML(typ="rt")
yaml.preserve_quotes = True
yaml.indent(mapping=2, offset=2, sequence=4)

The indent settings is relevant to be compatible with prettier formatting, at least if not having a rout-tripped format to retain.

exampleList:
- without-indent-settings

# this is the kind of formatting we systematically
# use and enforce with prettier, and requires explicit
# configuration of ruamel.yaml at least when generating
# new yaml files, but I'm uncertain if it's required when
# round-tripping on existing files with existing list entries
anotherExampleList:
  - with-indent-settings

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it! I remembered the indent setting (it's the same here), but forgot the quotes. Will fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@minrk minrk force-pushed the reverse-generated-spawner branch from 07c87f5 to 1959791 Compare March 8, 2022 11:33
minrk added 2 commits March 8, 2022 12:50
Make binderspawner_mixin.py canonical, instead of python-in-yaml

easier to edit with editors, linters, etc.

removes use of redundant pyyaml
@minrk minrk force-pushed the reverse-generated-spawner branch from 1959791 to a9ff870 Compare March 8, 2022 11:50
@minrk minrk requested review from manics and consideRatio and removed request for manics March 29, 2022 07:41
@manics manics merged commit ef354c0 into jupyterhub:master Mar 29, 2022
consideRatio pushed a commit to jupyterhub/helm-chart that referenced this pull request Mar 29, 2022
jupyterhub/binderhub#1459 Merge pull request #1459 from minrk/reverse-generated-spawner
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.

3 participants