feat: Upwards-recursively read .braintrust.json containing BRAINTRUST_API_KEY#166
feat: Upwards-recursively read .braintrust.json containing BRAINTRUST_API_KEY#166Luca Forstner (lforst) wants to merge 5 commits into
.braintrust.json containing BRAINTRUST_API_KEY#166Conversation
|
Discussed offline: Will move to reading JSON instead |
.env.braintrust containing BRAINTRUST_API_KEY.braintrust.json containing BRAINTRUST_API_KEY
|
David Elner (@delner) as discussed, updated the PR to use a |
David Elner (delner)
left a comment
There was a problem hiding this comment.
Overall, this iteration of this PR is a huge improvement over the last: not needing to add our own file parsing, elimination of threading both represent major simplifications that I think this needed. Kudos!
The guts of this seem fine. Before I approve though, I want to understand the strategic thinking a bit better. Right now there's some rough edges around Ruby convention and possible breakage of previous happy paths? (Where it previously operated without raising exceptions.) I think a little more context will help me assess this better.
| end | ||
| end | ||
|
|
||
| def require_api_key |
There was a problem hiding this comment.
This is awkward and non-idiomatic to Ruby. require suggests "loading", and I think it's unexpected that accessing this field would raise an error. Conventionally, if you want to signal an operation raises errors or mutates state, add a !, e.g. api_key!. This would be more acceptable.
Before we go that route: can you explain more of the background of why we want to separate the required vs non-required paths? Was the goal just not to repeat nil checks and error raising? Why are some call sites updated and not others?
Also a nit: I think key = @api_key is superfluous, and you could just use the instance variable directly in this case.
There was a problem hiding this comment.
Wo the distinction is that some code paths should not throw when attempting to look at the api_key, eg. Config.from_env, and some should indeed throw, like state.login.
Updated the non-idiomaticisms!
Direct port of braintrustdata/braintrust-sdk-javascript#2049
Prompt used: