Comments (6)
Oh yes, I didn't encounter this because my personal config was always a copy of the template, thanks for noticing this! strictyaml
seems to have optional keys with defaults, which we can use to replace the template file if we want to go that route. That might require a more helpful README file so that users don't have to dig into the code to understand what config options exist.
from mealpy.
We would need a second schema, with all optional keys. Being able to have a strict schema, with sane defaults, means the code can assume values exist. Otherwise we'll end up with a mess of .get('DEFAULT')
in the code, and it'll be difficult to document default values for the user.
I'm not sure how I feel about using optional keys feature of strictyaml
and schema validation features in general. it feels clunky to try to read the yaml schema via python code. Having a complete config template is a great way to self-document. The instructions could be yaml comments right in the config itself.
from mealpy.
We can specify the defaults within the schema for optional keys, so there won't be any issue about .get
and having to specify and defaults. As for readability, I think it would be possible to create our own "dictionary" containing values as tuple of (type, default)
instead of using the strictyaml.Map
directly, and just pass our custom dictionary into a helper function to generate the less readable schema.
Documentation is a good point though, but it's possible that users will go to the README anyway to learn how to use the tool, so it might also be a good idea to centralize all documentation in the README.
from mealpy.
I feel using optionals is a flawed approach. It complicates the schema, as a workaround. The schema should remain unchanged, as it's technically correct. Optionals makes it unclear to any developer wihtout tribal knowledge. We also don't want to maintain multiple schemas: one for the canonical schema; and the other for the "all-optionals".
I think we want to use revalidate, haven't looked at it closely though. What I'm envisioning is:
- validate the template, which should always be valid
- override/merge values from user config
- revalidate the final config, ensuring it's still valid.
That way, there should be less custom/duplicate code. It's just plain python assignments, and then reusing the same strictyaml
validation + schema setup.
from mealpy.
There will still only be one schema in my suggestion, except they are all optionals, which come with default values, which mirrors the idea of our "template config".
I think using revalidate will instead use a separate schema since strictyaml
needs to know how to read from the custom config.
from mealpy.
The schema with default values would work but the downside (imo quite significant) is that users cannot easily read the default values. Instead of reading a "config.template.yaml", they would need to read a strictyaml
schema.
strictyaml
can read a yaml file without schema.
from mealpy.
Related Issues (20)
- Stopped after one response 400 HOT 1
- Credentials should not be requested at module level HOT 3
- Pin requirements
- Add some tests HOT 2
- Script does not get password from keyring HOT 3
- Suggestions for improvements HOT 4
- Config not found HOT 1
- Script fails if restaurant or meal doesn't exist
- Setup travisci HOT 3
- Auth is only needed for some URLs HOT 2
- Handle reservation failure HOT 1
- Build is broken
- Limit reserving to during restaurant open hours HOT 1
- Add cli arguments HOT 1
- Update README
- Cache credentials so they don't need to be input every run HOT 5
- List restaurants, meals, and hours from cli HOT 4
- Scheduler doesn't work HOT 3
- Support meal preference priority HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mealpy.