Skip to content
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

Configuration reference interpolation #448

Merged
merged 2 commits into from
Dec 11, 2024
Merged

Conversation

kageurufu
Copy link
Member

@kageurufu kageurufu commented Dec 3, 2024

Constants are defined in a [constants] section, and unused constants will only warn instead of erroring.

My intended usage looks like this:

[constants]
run_current_ab: 1.9

[tmc5160 stepper_x]
run_current: ${constants.run_current_ab}
[tmc5160 stepper_y]
run_current: ${constants.run_current_ab}

${option} references the current section
${section.option} looks up anywhere

interpolation occurs at most 10 times right now to avoid infinite loops

Checklist

  • pr title makes sense
  • squashed to 1 commit
  • added a test case if possible
  • if new feature, added to the readme
  • ci is happy and green

@kageurufu kageurufu requested a review from a team as a code owner December 3, 2024 20:15
@kageurufu kageurufu force-pushed the dev/configfile_interpolation branch from 0848790 to e660f7c Compare December 3, 2024 20:17
@kageurufu
Copy link
Member Author

kageurufu commented Dec 3, 2024

As a note, nested lookups do not work right now

${section.${section.name}_name} is awful, but should it work anyway?

edit: now they work. this hurts my soul but it works

[constants]
run_current_xy = 1.9
run_current = run_current
xy = xy

[tmc5160 stepper_x]
run_current: ${constants.${constants.run_current}_${constants.xy}}

@rogerlz
Copy link
Contributor

rogerlz commented Dec 3, 2024

I believe it implement what has been asked in https://github.com/DangerKlippers/danger-klipper/issues/342

@kageurufu
Copy link
Member Author

I hadn't even looked for the issue. Enjoy @lraithel15133 🙃

@kageurufu kageurufu force-pushed the dev/configfile_interpolation branch from d6c184f to 9a46bc0 Compare December 3, 2024 23:53
@rogerlz rogerlz force-pushed the dev/configfile_interpolation branch 2 times, most recently from 33e0061 to d7ef907 Compare December 10, 2024 20:00
@kageurufu kageurufu force-pushed the dev/configfile_interpolation branch from 1cc29f1 to f717bfc Compare December 10, 2024 22:10
Constants are defined in a `[constants]` section, and unused constants will
only warn instead of erroring.

My intended usage looks like this:
```
[constants]
run_current_ab: 1.9

[tmc5160 stepper_x]
run_current: ${constants.run_current_ab}
[tmc5160 stepper_y]
run_current: ${constants.run_current_ab}
```

`${option}` references the current section
`${section.option}` looks up anywhere

interpolation occurs at most 10 times right now to avoid infinite loops
@kageurufu kageurufu force-pushed the dev/configfile_interpolation branch from f717bfc to 7440230 Compare December 11, 2024 19:07
@rogerlz rogerlz merged commit 86d1f55 into main Dec 11, 2024
3 checks passed
@rogerlz rogerlz deleted the dev/configfile_interpolation branch December 11, 2024 19:50
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.

2 participants