-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
info: use prob specs cache #605
Conversation
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.
Approving the changes in 15ac68d
This stops baking the prob-specs data into the binary, and make `configlet info` use the cached prob-specs directory like `configlet sync`. Advantages: - The prob-specs data is updated at run time; we no longer need commits like b54fe48 or 146d41c, and can remove `prob_specs_exercises.json` - The size of the configlet executable is reduced by 12 KiB (2.5%) - Fewer lines of code: we can remove `bin/write_probspecs_info.nim` Disadvantages: - The user must now pass `-o` or `---offline` when running `configlet info` with no/limited network connectivity. - `configlet info` is slower, even when using `-o`, because we run a few `git` commands to validate the cache repo. Closes: 483
15ac68d
to
ad4fbc4
Compare
@@ -1,6 +1,6 @@ | |||
import std/[algorithm, os, sequtils, sets, strformat, strutils, sugar, terminal] | |||
import pkg/jsony | |||
import ".."/[cli, types_track_config] | |||
import ".."/[cli, sync/probspecs, types_track_config] |
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.
We could refactor later so that the types/procedures for cloning and validating prob-specs are in a common location.
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've checked that, with this PR, the output of configlet info -o
is the same on every track as that with configlet info
before this PR.
exerciseFmt*: string | ||
updateFmt*: bool | ||
yesFmt*: bool | ||
of actInfo: | ||
offlineInfo*: bool | ||
of actSync: | ||
exercise*: string | ||
offline*: bool |
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.
offline
and offlineInfo
is consistent with e.g. exercise
and exerciseFmt
. But maybe it's better to move to offlineSync
and exerciseSync
later.
As a reminder, they can't both be called offline
unless we make --offline
a global flag. The relevant RFC is nim-lang/RFCs#368.
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.
Still waiting for the PR to implement that RFC...
func isOffline(conf: Conf): bool = | ||
(conf.action.kind == actSync and conf.action.offline) or | ||
(conf.action.kind == actInfo and conf.action.offlineInfo) |
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.
Similarly, more clunky than usual. It'd be nice if something like this were possible:
func isOffline(conf: Conf): bool =
conf.action.kind in {actInfo, actSync} and conf.action.offline
or just
if conf.action.offline
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.
if conf.action.offline
That would be sweet. We'll just have to wait I guess 🤷
This stops baking the prob-specs data into the binary, and makes
configlet info
use the cached prob-specs directory likeconfiglet sync
.Advantages:
commits like b54fe48 or 146d41c, and can remove
prob_specs_exercises.json
bin/write_probspecs_info.nim
Disadvantages:
-o
or---offline
when runningconfiglet info
with no/limited network connectivity.configlet info
is slower, even when using-o
, because we run a fewgit
commands to validate the cache repo.Closes: #483