cs50 / lib50 Goto Github PK
View Code? Open in Web Editor NEWThis is lib50, CS50's own internal library used in many of its tools.
License: GNU General Public License v3.0
This is lib50, CS50's own internal library used in many of its tools.
License: GNU General Public License v3.0
This dependency is only used in one place, that's to ask for username in _api.py
. This has been causing a headache for me as homebrew's readline recently upgraded to 8.0.0 and doesn't seem to cooperate with Python.
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 a file
HTTP parameter, https://cs50.readthedocs.io/sandbox/#configuration. In the context of HTTP, didn't seem appropriate to call it files
, since multiple files have to be provided one at a time, a la:
?file=foo.c&file=bar.c
But in the context of .cs50.yaml
, it seems a bit confusing to have lab50
use file
and have check50
and submit50
use files
. I could easily change over to files
, but then I'd run afoul of the tag requirement, which shouldn't apply to lab50
's use of files
:
https://cs50.readthedocs.io/sandbox/#configuration
How best to handle?
Check50 (3.0.8 with lib50 2.0.0) is giving me an error:
~/psets/module1/more/ (master) $ check50 minprog/cs50x/2019/mario/more -v
Connecting...
Authenticating...
Preparing...
INFO:lib50._api:git clone --bare ssh://[email protected]:443/me50/TheRijn/CS50x-psets .git
Looks like check50 isn't enabled for your account yet. Please go to https://submit.cs50.io in your web browser and try again.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 283, in prepare
_run(git.set(Git.cache)("clone --bare {repo} .git", repo=user.repo))
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 688, in _run
command_output = child.read().strip().replace("\r\n", "\n")
File "/usr/local/lib/python3.7/contextlib.py", line 119, in __exit__
next(self.gen)
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 681, in _spawn
raise Error()
lib50._errors.Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/check50", line 11, in <module>
load_entry_point('check50==3.0.8', 'console_scripts', 'check50')()
File "/usr/local/lib/python3.7/site-packages/check50/__main__.py", line 305, in main
commit_hash = lib50.push("check50", SLUG, internal.CONFIG_LOADER, data={"check50": True})[1]
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 69, in push
with authenticate(org, repo=repo) as user, prepare(tool, slug, user, included):
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 291, in prepare
raise Error(msg)
lib50._errors.Error: Looks like check50 isn't enabled for your account yet. Please go to https://submit.cs50.io in your web browser and try again.
Exception payload:
{}
My code lives in a git repo (TheRijn/CS50x-pests), this repo has a remove set via ssh with authentication via a deploy key.
This brakes ssh -oBatchMode=yes -p443 -T [email protected]
, it's returning.
Hi TheRijn/CS50x-psets! You've successfully authenticated, but GitHub does not provide shell access.
During all this debugging with @Jelleas I realised that the deploy key was set and probably giving these problems.
So this is nog a big as a problem as I thought, but still a nasty edge case.
On a related note to #62 and #63, should lib50
fetch with --depth 1
for local()
? That would make it much less punishing if someone commits a large file to the checks by accident, then removes the file, but without removing the commit from git. This came up in a conversation recently about adding reasonably large data files to checks.
Relevant snippet:
Line 144 in ca41d70
Here's an incredibly detailed explanation on how to keep a shallow clone up to date with fetch (again with --depth 1
):
https://stackoverflow.com/questions/41075972/how-to-update-a-git-shallow-clone/41081908#41081908
Password prompt in lib50 2.1.0+a5104c1 does not handle some special key correctly.
I'm testing using CS50 sandbox, and here's cat /etc/os-release
:
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
Running the submit50 3.0.3+70002d6 command with verbose argument:
submit50 cs50/problems/2019/fall/hello -v
Connecting...
Authenticating...
INFO:lib50._api:git -c credential.helper= -c 'credential.helper=cache --socket /root/.git-credential-cache/lib50' credential fill
GitHub username: siswa50
GitHub password:
If backspace is pressed when the password is empty:
GitHub password: Sorry, something's wrong! Let [email protected] know!
Traceback (most recent call last):
File "/usr/local/bin/submit50", line 11, in <module>
load_entry_point('submit50', 'console_scripts', 'submit50')()
File "/root/sandbox/submit50/submit50/__main__.py", line 147, in main
user_name, commit_hash, message = lib50.push("submit50", args.slug, CONFIG_LOADER, prompt=prompt)
File "/root/sandbox/lib50/lib50/_api.py", line 79, in push
with authenticate(remote["org"], repo=repo) as user, prepare(tool, slug, user, included):
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/root/sandbox/lib50/lib50/_api.py", line 282, in authenticate
with _authenticate_https(org, repo=repo) as user:
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/root/sandbox/lib50/lib50/_api.py", line 955, in _authenticate_https
password = _prompt_password(_("GitHub password: "))
File "/root/sandbox/lib50/lib50/_api.py", line 1040, in _prompt_password
password.pop()
IndexError: pop from empty list
Submission cancelled.
While the following are not a fatal error, it slightly annoying as the prompt can't handle some characters and just printing asterisks everytime these button pressed, like when pressing delete
button, and it can be deleted by pressing backspace
:
GitHub password: ****
Here's another that I've found so far:
tab
, esc
will add one asteriskF1
-F4
, home
, end
will add three asterisksdelete
, insert
, pageup
, pagedown
will add four asterisksF5
-F12
will add five asterisksRe https://github.com/cs50/lib50/blob/develop/lib50/config.py, best for caller to call load
twice?
To speed up the cloning process? https://github.com/cs50/lib50/blob/develop/lib50/_api.py#L456
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
referencing 0.34.0 requires attrs>=22.2.0, but you have attrs 20.3.0 which is incompatible.
jsonschema 4.21.1 requires attrs>=22.2.0, but you have attrs 20.3.0 which is incompatible.
check50 currently crashes when a branch that is a strict prefix of another already exists in the student repo. The crash is the result of git commit failing.
Lets have lib50 check for this and warn + exit if it detects such a branch.
referencing 0.34.0 requires attrs>=22.2.0, but you have attrs 20.3.0 which is incompatible.
jsonschema 4.21.1 requires attrs>=22.2.0, but you have attrs 20.3.0 which is incompatible.```
Check50 breaks when you try and run it with a slug that is a path:
~/vault50/mario/python/less/ (2018) $ check50 ~/problems/sentimental/caesar -v
Sorry, something's wrong! Let [email protected] know!
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/check50/__main__.py", line 303, in main
internal.check_dir = lib50.local(SLUG, offline=args.offline)
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 74, in local
slug = Slug(slug, offline=offline)
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 511, in __init__
self._check_endings()
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 548, in _check_endings
_("Invalid slug. Did you mean {}, without the leading slash?".format(self.slug.strip("/"))))
lib50._errors.InvalidSlugError: Invalid slug. Did you mean home/ubuntu/problems/sentimental/caesar, without the leading slash?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/check50", line 11, in <module>
load_entry_point('check50==3.0.3', 'console_scripts', 'check50')()
File "/usr/local/lib/python3.7/site-packages/check50/__main__.py", line 307, in main
raise_invalid_slug(SLUG, offline=args.offline)
File "/usr/local/lib/python3.7/site-packages/check50/__main__.py", line 211, in raise_invalid_slug
similar_slugs = lib50.get_local_slugs("check50", similar_to=slug)[:3]
File "/usr/local/lib/python3.7/site-packages/lib50/_api.py", line 405, in get_local_slugs
valid_paths.append(config_path.relative_to(local_path))
File "/usr/local/lib/python3.7/pathlib.py", line 876, in relative_to
.format(str(self), str(formatted)))
ValueError: '/home/ubuntu/check50/hello/.cs50.yml' does not start with '/home/ubuntu/.local/share/check50'
~/vault50/mario/python/less/ (2018) $
When trying to submit too many files (e.g., their node_modules
or virtual environment files). Ideally these files should be ignored but they shouldn't cause our tools to break if they're not.
Instead of trying SSH first then falling back to HTTPs, probably a good idea to give users more control over this. This also helps avoid the issue where SSH is misconfigured and trying to SSH into GitHub throws out an error instead of the expected output which causes submit50 to fail. We should also handle unexpected outputs by SSH.
And can we throw an exception if both .cs50.yml
and .cs50.yaml
are found so that a tool can advise a user to remove one? Am thinking that might be clearer than prioritizing one over the other?
This might be a bug in Lab but we need to dig into this to confirm.
Below seems to return all files of the form /some/path/*
rather than nothing?
print(lib50.files([], root="/some/path"))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.