diderot-edu / diderot-cli Goto Github PK
View Code? Open in Web Editor NEWA CLI interface for navigating through diderot.
A CLI interface for navigating through diderot.
it would be nice if diderot
could be run like this:
(invoke diderot with my course)
$ diderot 15210
this asks me to log in and sets my course by default this would be current semester
$ diderot Fall18 15210
would do the same as above but would find the Fall18 edition
after the user logs on like this, they would not have to provide course label to the queries, which is a bit cumbersome.
preferably one that is statically typed, and compiled.
I have some issues/improvements I want to report, including:
Discussion with iliano has brought up a good question -- should this actually be an embedded console? If it is more useful to just run individual commands, then perhaps we should just have a true CLI instead.
I believe we should collect some feedback from both students and administrators before making a full decision.
do stuff like adjust homework handout etc.
title
allow PDF chapters to be included
have point branch releases so that it's easy for people to get a particular version of the CLI.
Diderot distinguishes between two kinds of books, those with & without parts. The latter are called booklets. Most people will use these. The create chapter currently seems to require a part even if the book is a booklet. See below
create_chapter --number 15 --title 'Chapter from CLI' BAL
create_chapter --number 15 --title 'Chapter from CLI' BAL
usage: create_chapter [-h] --part PART --number NUMBER [--title TITLE]
[--label LABEL]
book
create_chapter: error: the following arguments are required: --part
Title
can't seem to find course and list courses
bash-3.2$ ./diderot
Username: diderot
Password:
Successfully logged in to Diderot.
DiderotCLI >> list_assignments 15210:S19
list_assignments 15210:S19
Invalid input course label.
Error retrieving all assignments.
DiderotCLI >> list_assignments 15210:S19
list_assignments 15210:S19
Invalid input course label.
Error retrieving all assignments.
DiderotCLI >> list_courses
list_courses
Unable to make a request to Diderot.
Error retrieving all courses.
the cli is literally drowning in technical debt -- new changes are quite difficult to make...
Checks your login authentication -- if you aren't a staff or ta member command fails.
Per iliano's request.
The chapter and book models have some new fields, so we want to make sure they are initialized properly. In particular, the use_parent_dost_assignment_rules
field is important. It looks like when a new chapter is created, this field is set to False (though the default value is True so not sure why this is the case). I assume the same thing is true for book creation.
allow setting various parameters
Instead of actual dates, it could be better to use
week#/day/time notation
THis would make json's reusable between different esemesters.
For example 11/2/23:05 means 11th week 2 day of the week 11:05pm.
Note first day of the week is determined by the start day of the course, typically Sunday or Monday.
Note also there is a timezone issue, maybe we can use the course time zone to do this
Perhaps allow both:
Data should output correctly and readably in the CLI. Tab spacing between output is not enough.
once a book json spec is written it has all the information needed to upload a chapter (e.g., name of pdf/xml files, attachments, etc) so we can use it to upload single chapters and parts. For example, like this
diderot_admin upload-book --only-chapter < chapter number >
diderot_admin upload-book --only-part < part number >
Codehomeworks is being rewritten, so the CLI should be updated to handle that.
Suggestion from Gaurav -- use an auth file instead of passing the password in through the arguments.
allow booklet and book to be specified as a json file and be created and uploaded wholesale
{book: exam/,
title: Exam 1,
label: EXAM1,
chapter : {
xml: truefalse/truefalse.xml,
pdf: truefalse/truefalse.pdf
}
chapter: {
xml: shortanswers/shortanswers.xml,
attachments: shortanswers/media,
pdf: hortanswers/shortanswers.pdf
},
chapter {
xml: dfs/dfs.xml,
attachemnts: dfs/media,
pdf: dfs/dfs.pdf
}
}
{book: exam/,
title: Exam 1,
label: EXAM1
part 1: {
label: part:truefalse,
title: True-False Problems,
chapter : {
xml: truefalse/truefalse_version1.xml,
pdf: truefalse/truefalse_version1.pdf
}
chapter : {
xml: truefalse/truefalse_version2.xml,
pdf: truefalse/truefalse_version2.pdf
}
},
part 2: {
label: part:shortanswers,
title: Short Answers,
chapter: {
xml: shortanswers/shortanswers_version1.xml,
attachments: shortanswers/media_version1,
pdf: hortanswers/shortanswers_version1.pdf
},
chapter: {
xml: shortanswers/shortanswers_version2.xml,
attachments: shortanswers/media_version2,
pdf: hortanswers/shortanswers_version2.pdf
}
}
part 3: {
label: part:dfs,
title: Depth First Search
chapter {
xml: dfs/dfs.xml,
attachemnts: dfs/media,
pdf: dfs/dfs.pdf
}
}
}
Can spin up a simple testing server and connect to that, and have sample data given back at each api call. This can test a variety of things and help further development.
Set due/release date
Clear due/release date
Use week#/day/time notation rather than exact date so that it is reusable across semesters
For example 11/2/23:05 means 11th week 2 day of the week 11:05pm.
Note first day of the week is determined by the start day of the course, typically Sunday or Monday.
Courses on Diderot have both a number (not necessarily unique), and a label (which is unique). Right now, all interfacing with courses is through the label, which is not intuitive. To make this better, it would be nice to just support inputting both labels and numbers, and fall back to a label if there are multiple courses with the same number.
Diderot accepts single file handins, as well as tar files. However, diderot needs to be told which type of file is being sent so that it handles it correctly. Doing this would involve checking what type of file is being uploaded, and populating the request headers with the correct keys using that information.
The api_calls.py right now is littered with logic that checks if a user is logged in or not. This doesn't seem important right now, so we should remove it.
our new course labels include spaces commas etc. this leads to an error
make list_chapters
/Users/umut/diderot/diderot-cli/diderot_admin list_chapters "CMU:Pittsburgh, PA:15210:Spring:2019-20" "TB"
Invalid input course label.
Error listing chapters.
make: *** [list_chapters] Error 1
bash-3.2$
A very basic guide to CLI would be helpful. Add this as a separate chapter in the repo guide
As a stub, I created cli/cli.tex, and put in an outline.
Makefile should work.
I got stuck when trying to update a chapter. I used the command incorrectly but there was no "help".
bash-3.2$ admin/diderot_admin
admin/diderot_admin
Username: ..
Password: ..
Successfully logged in to Diderot.
DiderotCLI >> help
help
Documented commands (type help <topic>):
========================================
EOF help list_courses update_assignment
download_assignment list_assignments quit update_book
exit list_books submit_assignment
DiderotCLI >> update_book guide mtl --xml ~/diderot/guide/mtl/mtl.xml
update_book guide mtl --xml ~/diderot/guide/mtl/mtl.xml
Failure uploading book.
DiderotCLI >> help update_book
help update_book
the CLI needs to be put on AFS in the 15210 folder, in read-only mode. Ideally this setup would involve using a git hook, so that whenever pushes are made to master, the repository on AFS automatically pulls.
For reference -- https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
Similar to AWS, we put the path to a credentials file in an environment variable, or we can expect it to always be in a place?
Such as ~/.diderot/credentials
would be nice to be able to create a part from the CLI.
Right now, all the functions in api_calls.py return None or some arbitrary value when something fails. It would be better to have more descriptive error messages / handling when something goes wrong, so that users can be notified of what to do.
Should the title be a string? I wasn't able to create a chapter with a title like this "Chapter from CLI"
For this command, displaying an example would help.
codehomeworks had their numbers removed, so that should be removed from the CLI
It needs unit tests.
Umut suggested a few aliases, such as cc -> set_course, mc -> make chapter etc. Set up a framework for easily handling aliases.
the list_books command doesn't seem to take current course into account and seem to list all courses
...
Successfully logged in to superuser.
DiderotCLI >> list_books
list_books
book:problem-sets book:textbook book:lecture-notes notes slides TB course-notes book:slides Miscellaneous book:homeworks homeworks slides guide book:recitations Notes books:solns hw book:recitations textbook Slides LIBDOC REC book:slides book:lecture-notes slides mics book:homework book:miscellaneous labs textbook book:recitations book:writtens prog book:textbook book:lecture-notes book:lecture-slides BAL
DiderotCLI >> list_courses
list_courses
15122-N19 15281-N19 15780:S19 15251:s19 15122-DEVELOPMENT 15359-fall09 15388:DEV 15388:f19 15210:S19 cs109-dev 15000:diderotguide:f19 utah-3100:modelsofcom 15819:quantpa:f19 15251:f19 15455:f19 15210:F19 15122:f19
DiderotCLI >> set_course 15210:S19
set_course 15210:S19
Course set successfully.
DiderotCLI/15210:S19 >> list_books
list_books
book:problem-sets book:textbook book:lecture-notes notes slides TB course-notes book:slides Miscellaneous book:homeworks homeworks slides guide book:recitations Notes books:solns hw book:recitations textbook Slides LIBDOC REC book:slides book:lecture-notes slides mics book:homework book:miscellaneous labs textbook book:recitations book:writtens prog book:textbook book:lecture-notes book:lecture-slides BAL
add create book command
If book is not found, then create it with the given
Example:
"book" : "TB.VOL.1",
"title": "Textbook (Volume I)"
"parts": [
...
I recall that we talked about this but I am not sure if it has been implemented. It would be nice to allow instructors and TA's to upload chapters like this
$ did upload -book <book label> -chapter <chapter number> -attach path/to/attachments path/to/chapter/main.[xml | pdf]
Once invoked, this command could terminate immediately, but it would be better if it "spun" its wheels, e.g., by printing a "." every 1 seconds or so and then take the return value from the chapter upload and print it.
This requires some coordination between the book uploads API. Perhaps the trickiest part is that it would have to construct a request object with file attachments (e.g., typically some image files).
How much work would this require?
This allows us to use this in scripts and integrate this with CI systems
possibly others
Release/Publish Date?
Umut brought up a good point, that if we always look ~/.diderot/credentials, then that will encourage students to store their passwords in that location. However, that location by default is not private on AFS, and it could lead to students seeing other student's passwords. We need a way to work around this.
This (PR #8) is great!!
I have a few suggestions for the command arguments.
Recall the command is
update_book <book label> <chapter label> [--pdf [--video_url] | --slides [--video_url] | --xml [--images] [--xml_pdf] ]
book label
isn't unique across courses. so this CLI would not know which course to update. perhaps change this so that it logs you onto a course, as I suggested in #10.chapter label
is not user friendly here because it will likely be a mambo jambo string maybe just include the number?change the name to `upload_chapter'
Change images
--> attach
We migth want to attach anything. I don't recall how this works, but it would be best if it took a directory and took everything within that directory (also recursively) and uploaded onto diderot (as a list of files), e.g.,
dirA/fileA.png
dirA/dirAA/fileAA.jpg
would upload both files fileA.png and fileAA.png.
DiderotCLI/15210:S19 >> update_book --xml ~/diderot/15897/lambda/lambda.xml --images ~/diderot/15897/lambda
update_book --xml ~/diderot/15897/lambda/lambda.xml --images ~/diderot/15897/lambda
usage: update_book [-h] [--pdf PDF] [--slides SLIDES] [--video_url VIDEO_URL]
[--xml XML] [--images IMAGES [IMAGES ...]]
[--xml_pdf XML_PDF]
book chapter
update_book: error: the following arguments are required: book, chapter
DiderotCLI/15210:S19 >> update_book --xml ~/diderot/15897/lambda/lambda.xml --images ~/diderot/15897/lambda TB 61
update_book --xml ~/diderot/15897/lambda/lambda.xml --images ~/diderot/15897/lambda TB 61
usage: update_book [-h] [--pdf PDF] [--slides SLIDES] [--video_url VIDEO_URL]
[--xml XML] [--images IMAGES [IMAGES ...]]
[--xml_pdf XML_PDF]
book chapter
update_book: error: the following arguments are required: book, chapter
DiderotCLI/15210:S19 >> update_book --xml ~/diderot/15897/lambda/lambda.xml TB 61
update_book --xml ~/diderot/15897/lambda/lambda.xml TB 61
Begin upload to Course: 15210:S19, Book: TB, Chapter Number: 61, Chapter Title: CLI-CHAPTER? Enter yes to proceed. Any other input will cancel the upload.
yes
yes
Waiting for book upload to complete...
would be nice to have a single makefile that could
Do we need slides
and pdf
separately? They should be doing the same thing.
Maybe add in some information about navigating chapters -- see chapters, provide links to new chapters / sections? Might be useful.
CLI seems to "allow" a student to create a part. it says that it created the part even though it didn't.
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.