kcl icon indicating copy to clipboard operation
kcl copied to clipboard

Collect instances of schema

Open steeling opened this issue 10 months ago • 3 comments

MySchema.instances() is a really nice helper function, however seems to work in limited circumstances. Is there a way to pull instances across multiple files, or a glob of files (or all files in a single directory)?

steeling avatar Mar 29 '24 03:03 steeling

Currently, MySchema.instances() it is only valid for files in the main package to avoid unexpected non idempotent calls. For example, I instantiated a MySchema in pkg1, but the length of the list returned by calling the instances method in other packages is uncertain. Therefore, the current general usage is kcl main1.k main2.k, that is, instantiate MySchema in main1.k and call the instances method in main2.k

Peefy avatar Mar 29 '24 03:03 Peefy

When dealing with 100's of configs it's nice to use multiple files, and would be nice to have some way to aggregate them back together. Not an unsolvable problem without it, but a nice to have :)

Though I definitely see the need to be careful, as it could be used in unintended scenarios

steeling avatar Mar 29 '24 03:03 steeling

Thank you! but we will still carefully consider this scenario and develop more suitable solutions and features. ❤️

Peefy avatar Mar 29 '24 03:03 Peefy