Skip to content
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

Merged
merged 84 commits into from
Jun 10, 2019
Merged

feat: add MFS tutorial #200

merged 84 commits into from
Jun 10, 2019

Conversation

terichadbourne
Copy link
Member

  • Uncomment MFS lessons in main.js
  • Add MFS tutorial to courses in courses.json

- Uncomment MFS lessons in `main.js`
- Add MFS tutorial to courses in `courses.json`
@terichadbourne
Copy link
Member Author

@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 { long: true}. If I forget to include that and submit the code, it shows the correct logDesc and log. However, if I then add the { long: true } and hit submit again, only the logDesc updates, not the log.

if I reset code and paste in the same correct answer with { long: true } included, both the logDesc and log are correct.

@fsdiogo
Copy link
Collaborator

fsdiogo commented Apr 24, 2019

@terichadbourne just fixed the #200 (comment) issue in PR #206.

@fsdiogo fsdiogo closed this in #206 Apr 26, 2019
@fsdiogo fsdiogo reopened this Apr 26, 2019
@fsdiogo
Copy link
Collaborator

fsdiogo commented Apr 26, 2019

Closed this one by accident, sorry. Already synced with the code highlighting fix from code.

@terichadbourne
Copy link
Member Author

Heads up that @olizilla and I have reworked the proposed layout for lesson order in the issue: #91 (comment)

@terichadbourne
Copy link
Member Author

@fsdiogo @olizilla Can either of you easily figure out what's broken in MFS lesson 3 (the new stat lesson)? I'm getting

Syntax Error: SyntaxError: /Users/terichadbourne/code/pl/protoschool/proto.school/src/tutorials/Mutable-File-System/03.vue: 'import' and 'export' may only appear at the top level (50:0)

  48 | const modules = { cids: require('cids') }
  49 | 
> 50 | export default {
     | ^
  51 |   components: {
  52 |     Lesson
  53 |   },

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.

@fsdiogo
Copy link
Collaborator

fsdiogo commented Apr 29, 2019

@terichadbourne yup, you're missing an } on line 30 😄

@terichadbourne
Copy link
Member Author

Thanks @fsdiogo! 🤦‍♀️

@fsdiogo fsdiogo changed the title WIP: Add MFS tutorial feat: add MFS tutorial May 23, 2019
@fsdiogo
Copy link
Collaborator

fsdiogo commented May 23, 2019

@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!

Copy link
Member

@alanshaw alanshaw left a 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).

src/tutorials/Mutable-File-System/01.md Outdated Show resolved Hide resolved
src/tutorials/Mutable-File-System/01.md Outdated Show resolved Hide resolved
@@ -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.
Copy link
Member

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?

Copy link
Collaborator

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.

Copy link
Member Author

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.
Copy link
Member

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.

Copy link
Member Author

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"?

Copy link
Member Author

@terichadbourne terichadbourne Jun 5, 2019

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.

src/tutorials/Mutable-File-System/02.md Outdated Show resolved Hide resolved
src/tutorials/Mutable-File-System/02.md Outdated Show resolved Hide resolved
Copy link
Member

@alanshaw alanshaw left a 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 })))
Copy link
Member

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?

src/tutorials/Mutable-File-System/06.md Outdated Show resolved Hide resolved
src/tutorials/Mutable-File-System/05.md Outdated Show resolved Hide resolved
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.
Copy link
Member

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!

Copy link
Member Author

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a screenshot from the console if I try to use some .key files and .pdf files.
image

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

src/tutorials/Mutable-File-System/08-exercise.md Outdated Show resolved Hide resolved
src/tutorials/Mutable-File-System/09.md Show resolved Hide resolved
@terichadbourne
Copy link
Member Author

@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.

src/static/tutorials.json Outdated Show resolved Hide resolved
Copy link
Member

@mikeal mikeal left a 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.

@fsdiogo
Copy link
Collaborator

fsdiogo commented Jun 6, 2019

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:

spin

After hitting Submit, the button text changes to a spinner and the button gets disabled until the validation ends. This is now working for all lessons.

@terichadbourne
Copy link
Member Author

Great idea with the spinner @fsdiogo! Thank you!

@terichadbourne terichadbourne removed the request for review from ericronne June 7, 2019 17:08
@terichadbourne terichadbourne merged commit b111973 into code Jun 10, 2019
@terichadbourne terichadbourne deleted the feat/mfs-tutorial branch June 10, 2019 17:00
@terichadbourne
Copy link
Member Author

I've gone ahead and merged this but feedback is always welcome through issues or PRs. Thanks for all the hard work, everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants