-
Notifications
You must be signed in to change notification settings - Fork 476
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
algocfg: Add relay profile, algocfg profile cmd #5069
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5069 +/- ##
==========================================
- Coverage 53.44% 53.39% -0.05%
==========================================
Files 431 432 +1
Lines 54369 54409 +40
==========================================
- Hits 29057 29052 -5
- Misses 23053 23099 +46
+ Partials 2259 2258 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
if err != nil { | ||
reportErrorf("%v", err) | ||
} | ||
file := filepath.Join(dataDir, config.ConfigFilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a A config.json file already exists for this data directory. Would you like to overwrite it? (Y/n)
prompt in case there is already a config file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish it had a "-y"/"--yes" or "-f"/"--force" option to skip the prompt, or "-w" to overwrite. New to the problem I'm not strongly opinionated on which one feels right. Maybe "-f".
ALSO, I wish it was an update not an overwrite. A "default" to reset things makes sense as one option, but "relay" could just set the 4 fields it wants to set on top of an existing config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--yes
looks required to use in shell scripts
7e5e17c
to
1d0d604
Compare
if err != nil { | ||
reportErrorf("%v", err) | ||
} | ||
file := filepath.Join(dataDir, config.ConfigFilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--yes
looks required to use in shell scripts
return | ||
} | ||
} | ||
err = codecs.SaveNonDefaultValuesToFile(file, cfg, config.GetDefaultLocal(), nil, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: improvement idea: implement SaveNonDefaultValuesToWriter
that works with not a file but a stream (and SaveNonDefaultValuesToFile
just calls it) so that list profiles could also print non-default values in this profile.
Or allow outputting to stdout instead of config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, let me add that in a separate PR.
if _, err := os.Stat(file); err == nil { | ||
fmt.Printf("A config.json file already exists for this data directory. Would you like to overwrite it? (Y/n)") | ||
reader := bufio.NewReader(os.Stdin) | ||
resp, err := reader.ReadString('\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe ReadRune
cmd/algocfg/profileCommand.go
Outdated
|
||
func getConfigForArg(configType string) (config.Local, error) { | ||
cfg := config.GetDefaultLocal() | ||
switch configType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe store the config generator function along with the array of profile names as opposed to this switch statement that will get appended to
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
Updated behavior
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no stdout support but lgtm
Summary
Adds a new config from which algocfg and set defaults separately from the Local defaults.
Some things that are troublesome w/ the way we use tags for config values.
The new commands: