-
Notifications
You must be signed in to change notification settings - Fork 16
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
how handle use of files
in lab50?
#8
Comments
The When we wrote this we envisioned You probably do want all the work we do for the Something like this perhaps?: loader = lib50.Loader()
loader.register(tag1, lambda value: Foo(value)) # loader.register(tag1, Foo)
loader.register(tag2, lambda value: Bar(value))
loader.load(config, "lab50") This would let |
Relying on
so as to signal which tabs to open. So this would be handy. Could we perhaps avoid the need for a custom class per tag? Simpler would be a single wrapper class (e.g.,
Feels like a lot less overhead than defining one class per tag? |
Sure, that's what we do with
|
Should we perhaps simplify, though, so that we don't need to pre-define types, instead just setting properties to |
We could, it just (a) makes it tougher to validate that the user didn't specify invalid tags, which we would want to error on and (b) the syntax wouldn't be quite as nice as your proposal (without resorting to some Also, as a general rule I think it is generally good practice to not allow an API to represent invalid states. It is possible for |
Hm, having to register valid tags seems reasonable, in the spirit of:
But:
|
|
|
Oh! We could do something like that! We can register a so-called multi-constructor (matching a prefix of a tag). That would just wrap every tagged string with a custom String (better name pending) class. Then the interface could just be:
We don't even need to hack in |
The |
Would it not be safer to wrap all
before accessing |
You're probably not checking That said we don't need Coming back to my point earlier, since |
Okay, not every part, but how about when tags are optional? For labs, I think the common case will be "install these files and open them for the student," via:
And it seems silly to require instead
for the common case. So I'd envision a common scenario of, e.g.:
or, equivalently:
How best to accommodate optionality, then, without forcing use of |
I'd envision a flag in the loader (for that scope if we support local tag scope) something like So for lab50 it could be:
Or:
Edit: |
Yeah, I think values can only have one tag, right? If so, setting a default tag is probably better than a default value, since (accidental) code like
would seem to create an ambiguity otherwise? |
Implemented a working concept of Line 26 in 7250882
Unittests here: Line 6 in 7250882
Interface is as follows: loader = lib50.Loader("<TOOL>", "<GLOBAL_TAG_1>", "<GLOBAL_TAG_2>", ..., default="<DEFAULT_TAG>")
loader.scope("<KEY>", "<LOCAL_TAG_1>", "<LOCAL_TAG_2>", ..., default="<DEFAULT_TAG>")
loader.load(content) For loader = lib50.Loader("check50")
loader.scope("files', "include", "exclude", "require")
loader.load(content) For loader = lib50.Loader("lab50")
loader.scope("files", "closed", default="opened")
# or if !opened needs to be a valid tag
# loader.scope("files", "closed", "opened", default="opened")
loader.load(content) Currently you can only scope keys exactly one level deep (top-level is reserved for tools). That means you can scope keys like As a result from I really like scopes here even in the case of ps. I have not integrated any of this with |
Here is how we currently envision lab50 can use Lines 433 to 471 in 7356e65
|
Few questions:
|
Line 453 in 7356e65
Implemented the default behavior for this comment from last year (#8 (comment)):
|
So right now, lab50 supports a
file
key, which is either a string or a list of strings, which is based on CS50 Sandbox's support for afile
HTTP parameter, https://cs50.readthedocs.io/sandbox/#configuration. In the context of HTTP, didn't seem appropriate to call itfiles
, since multiple files have to be provided one at a time, a la:But in the context of
.cs50.yaml
, it seems a bit confusing to havelab50
usefile
and havecheck50
andsubmit50
usefiles
. I could easily change over tofiles
, but then I'd run afoul of the tag requirement, which shouldn't apply tolab50
's use offiles
:https://cs50.readthedocs.io/sandbox/#configuration
How best to handle?
The text was updated successfully, but these errors were encountered: