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

Hardwired path to jupytergraffiti_data #21

Closed
psychemedia opened this issue Apr 25, 2019 · 7 comments
Closed

Hardwired path to jupytergraffiti_data #21

psychemedia opened this issue Apr 25, 2019 · 7 comments

Comments

@psychemedia
Copy link

I notice that you're using a hardwired path to jupytergraffiti_data here.

It would be useful if this path could be set by the jupytergraffiti screencast creator (eg they might want to specify a hidden directory or a common directory referenced from several directories containing their own graffitied notebooks), perhaps via a metadata editor / panel reached from / on the graffiti control panel?

A guard to check the existence of, and create otherwise, the directory would probably also make sense?

@willkessler
Copy link
Owner

willkessler commented Apr 25, 2019

Thank you for the suggestion!

What I'm thinking is that when you Activate Graffiti on a notebook, you can enter an (optional) jupytergraffiti_data path (relative to the notebook's path) in the confirmation dialog. This will then be stored in the graffiti data block in the notebook-level metadata where you could change it later if you so desired using Jupyter's regular metadata editing facility.

e.g.

 "metadata": {
  "graffiti": {
   "firstAuthorId": "dev",
   "id": "id_hvkb0pc",
   "language": "EN",
   "dataPath": "../other_path",
   "markdownLocked": false
  },
...

That is, unless you meant a different path for every single graffiti? This wouldn't work because every notebook has its own single manifest file, containing information about all the graffiti in the notebook.

@willkessler willkessler pinned this issue Apr 25, 2019
@psychemedia
Copy link
Author

Hi

Re: diffferent paths, I was meaning the notebook level.

So eg I might have:

notebooks/
  .graffitibits/
  week1/
    nbactivity1.ipynb
    nbactivitiy2.ipynb
  week2/
    nbactivity3.ipynb

with all the graffiti stuff in the common, hidden directory?

Providing a path via notebook metadata would be handy (notebook arguably needs a more streamlined metadata editing route I think?).

With all the metadata, I'm wondering if/how jupytergraffiti will work with things like jupytext. Latest v1.1 jupytext release supports metadata in the .md dual format I think?

@willkessler
Copy link
Owner

willkessler commented Apr 25, 2019

 .graffitibits/
 week1/
   nbactivity1.ipynb
   nbactivitiy2.ipynb
 week2/
   nbactivity3.ipynb

^^ seems quite doable. Note that you are asking that the directory name for the data is also specified... ie, you want to be able to say something like:

"metadata": {
  "graffiti": {
   "firstAuthorId": "dev",
   "id": "id_hvkb0pc",
   "language": "EN",
   "dataPath": "../../.graffitibits",
   "markdownLocked": false
  },

... and it would not use jupytergraffiti_data as the folder name at all. Right?

Not sure about jupytext, don't have much familiarity with it. If it leaves graffiti metadata at the notebook and the cell level alone, then things should work except for the graffiti added to markdown cells. These are positioned by placing html tags around the text involved. If jupytext should strip these then you'd lose access to the graffiti. (In code cells, the positions of the graffiti are kept via token tracking, not by modifying the code cell contents directly, so that should make it through).

Perhaps you can give jupytext a try and see what transpires?

@psychemedia
Copy link
Author

psychemedia commented Apr 25, 2019 via email

@willkessler
Copy link
Owner

Sounds good, we should have the customizable data path ready before you get back :-)

@willkessler
Copy link
Owner

Turns out we cannot use a hidden directory because Jupyter will not serve content from hidden directories for security reasons (jupyter/notebook#2382 (comment)). However, you can name the folder with some prefix like _ to separate it from other types of folders. Stay tuned, this code is almost pushed...

@willkessler
Copy link
Owner

@psychemedia You can now change the data path. If you pull the latest version of the repo, you will now find the Graffiti Editor panel has a button for changing the data path and folder. It looks like this:

changeDataDirIcon

When you click the icon, you will then be prompted to specify a data path as shown here:
changeDataDirIcon2

You can specify a relative path vis-a-vis your notebook's location. Note:

  • You cannot use hidden (.-prefixed) directories in the path name as Jupyter will not serve data to Graffiti from those directories for security reasons
  • If you change the data path after you've created some Graffiti for the current notebook then you will lose access to those Graffiti. Probably best to change the data path right after you Activate Graffiti.

@willkessler willkessler unpinned this issue Jun 8, 2019
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

No branches or pull requests

2 participants