-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat: add MFS tutorial #200
Conversation
- Uncomment MFS lessons in `main.js` - Add MFS tutorial to courses in `courses.json`
@fsdiogo I'm having a problem with your new UI logging feature as i work on lesson 4. I just adjusted the message for when you forget if I reset code and paste in the same correct answer with |
- Add updates from the solution viewing feature
@terichadbourne just fixed the #200 (comment) issue in PR #206. |
Closed this one by accident, sorry. Already synced with the code highlighting fix from |
Rework lesson order
Heads up that @olizilla and I have reworked the proposed layout for lesson order in the issue: #91 (comment) |
@fsdiogo @olizilla Can either of you easily figure out what's broken in MFS lesson 3 (the new stat lesson)? I'm getting
But I had gone back to the boilerplate (for Lesson, not FileLesson) and copied the bottom part so I'm not clear what's going wrong here. |
@terichadbourne yup, you're missing an |
Thanks @fsdiogo! 🤦♀️ |
@terichadbourne @olizilla finished the lessons that were missing validation. Their validation isn't as extensive as @terichadbourne standard (😄) but I think it's enough for a test run. When you have the time to take a look at this, please do! |
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.
Sometimes "folder" is used and sometimes "directory" - I would be consistent (and use "directory", since this is what's used internally).
@@ -1,5 +1,26 @@ | |||
As a matter of security, web browsers don't let us change files that live on your computer. Therefore you'll need to upload one or more files to the browser that you can use throughout this tutorial. | |||
## Working with files in ProtoSchool | |||
Here in our ProtoSchool tutorials, rather than using your machine itself, we're creating a new IPFS node for you in the browser each time you hit the "Submit" button in a lesson. Whenever you see `ipfs.someMethod()` in our lessons, `ipfs` is a variable that refers to your IPFS instance, also known as a node. The actions that you take only affect your own IPFS node, not nodes belonging to your peers. |
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.
Here in our ProtoSchool tutorials, rather than using your machine itself, we're creating a new IPFS node for you in the browser
I'm not sure I understand this sentence...is it referring to the difference between running a daemon on your machine and running it in the browser?
I think this could be confusing to people, the browser is running on my machine, so how is IPFS not running on my machine?
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'm not sure I understand this sentence...is it referring to the difference between running a daemon on your machine and running it in the browser?
Yeah, I think @terichadbourne was trying to differentiate between having to install IPFS and run a daemon in your terminal from running an on-demand disposable one in the browser.
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.
Yeah, so essentially you can do all of ProtoSchool without ever learning to install IPFS. So we need to call out that we're skipping a whole step... which I can't describe accurately because I'm never done it NOT in the browser. Want to propose something that sounds accurate to you while still explaining what we're doing in the background?
|
||
Within each exercise, you'll see that you can upload from your computer either by dragging and dropping or selecting from your file explorer. If you look closely at the `run` function in the code editor, you'll notice that it now takes an argument `files`. When you upload files from your computer, we'll make sure they're passed into the function as the `files` array. As long as you don't refresh your browser, these files will remain accessible for the next lesson in the tutorial, but you'll also have the option to upload different files to work with for each lesson. | ||
We're creating your IPFS node behind the scenes so you can focus on the content of our lessons, but eventually you'll need to learn to host your own node locally. When you're ready to experiment, you can find instructions for [installing IPFS](https://docs.ipfs.io/introduction/install/) and [initializing your node](https://docs.ipfs.io/introduction/usage/) in our docs. |
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.
host your own node locally
Perhaps needs a rephrase? When running IPFS in the browser it is running locally as well, it's just running in your browser's sandbox.
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 never done it the other way, so perhaps you can help me describe it more accurately. Would it be "eventually you'll need to learn to IPFS and run a daemon in your terminal"?
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.
Let me know how this sounds to you @alanshaw. Does it address your concerns?
Here in our ProtoSchool tutorials, we create a new IPFS node for you in the browser each time you hit the "Submit" button in a lesson. Whenever you see
ipfs.someMethod()
in our lessons,ipfs
is a variable that refers to your IPFS instance, also known as a node. The actions that you take only affect your own IPFS node, not nodes belonging to your peers.We're creating your IPFS node behind the scenes so you can focus on the content of our lessons, but eventually you'll need to learn to host your own node locally by installing IPFS and running a daemon in your terminal. When you're ready to experiment, you can find instructions for installing IPFS and initializing your node in our docs.
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 I get answers wrong I don't get any output or error :(
I'm not sure how much this matters but I thought "stat" was short for "statistics" not "status".
let rootContents = await ipfs.files.ls('/', {long: true}) | ||
return rootContents | ||
// this code adds your uploaded files to IPFS | ||
await Promise.all(files.map(f => ipfs.files.write('/' + f.name, f, { create: true }))) |
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.
It's a bit odd to see this after we just did it with a loop. Why not just have the loop here again?
await ipfs.files.mv('/source-file.txt', '/destination-file.txt') | ||
``` | ||
|
||
**Note:** `files.mv` takes longer when you move larger files. If you've been working with large files for these lessons, please click "Start Over" above the file upload window and select smaller files. |
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.
Should not be true - has this been observed? It's a bug if so!
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.
@alanshaw I was getting no response when I submitted code for this lesson, and the thing that seemed to fix it was uploading smaller files, so I made an assumption. It's possible I misdiagnosed the problem, but it would be great if you or @fsdiogo could try completing lesson 8 with huge files and see if you can replicate the problem. Is it possible for that issue to be true in ProtoSchool but NOT on one's own locally installed IPFS for some reason?
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.
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.
@fsdiogo Would you be able to tell if it were the file upload stage and not the ipfs.files.mv stage causing the slowdown? Not sure if that screenshot above sheds any light.
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.
Just tested this and the slowdown isn't caused by the ipfs.files.mv
, as it happens in other MFS lessons that operates with the uploaded file.
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.
With commit f5d62e8 the user now gets feedback that something is in the works after submitting a lesson.
Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
@fsdiogo Thanks so much for getting that file copying working while I was out! I've updated the later lessons to force the user to create a name for the file when they copy it into MFS, since the point of MFS seems to be the ability to pretend we're using a name-based system and I was super annoyed during the 20 minutes today when I thought it wasn't possible. 😂 The last few lessons still don't appear to provide any validation for issues that would be caused by touching the wrong parts of the code, but I'm going to let the testers loose on it regardless. 🎉 @alanshaw I think between Diogo and I we've addressed the bulk of your concerns, but there were a couple of spots where I held back to see what other testers say. @dietrich and @ericronne have both offered to try it out and provide feedback late this week or early next week to ensure we can incorporate feedback before we head to Barcelona. Since this is the only ProtoSchool content currently planned for use at IPFS Camp, my gut feeling is that we should go ahead and publish it to the standard site before the event and use it from there, but if you feel we need any sort of camp-specific customization, please let us know. |
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.
LGTM, I think I even learned a few things about MFS reading the diff :)
I had one comment but it isn’t critical. Assuming the thread with Alan about mv
taking a long time for large files (which is quite odd, i wonder what is going there) is resolved this looks good to me.
I added a spinner for when the user submits a lesson! This is something I wanted to do for a while, but as we have MFS lessons that take some time to validate, now was the right moment to do it: After hitting |
Great idea with the spinner @fsdiogo! Thank you! |
I've gone ahead and merged this but feedback is always welcome through issues or PRs. Thanks for all the hard work, everyone! |
main.js
courses.json