Ticket #3844 (closed enhancement: fixed)

Opened 2 years ago

Last modified 7 months ago

notebook -- worksheet should call sys.path.append(DATA) when being initalized

Reported by: was Owned by: boothby
Priority: major Milestone: sage-4.3.2
Component: notebook Keywords:
Cc: Author(s): William Stein
Report Upstream: N/A Reviewer(s): Mitesh Patel
Merged in: sagenb-0.7 Work issues:

Description

If we do the above then one can upload/attach a .py file and import it in the worksheet, which is really sweet.

Attachments

sage-3844.patch Download (4.7 KB) - added by was 2 years ago.
sagenb_3844.patch Download (0.7 KB) - added by was 10 months ago.
apply only this -- ignore the old sage-3844.patch
trac_3844-DATA_in_sys_path.2.patch Download (1.9 KB) - added by mpatel 7 months ago.
Updates tutorial.py. Replaces previous.
trac_3844-DATA_in_sys_path.3.patch Download (1.8 KB) - added by mpatel 7 months ago.
Rebased for SageNB 0.6 + queue in comment. Replaces previous.

Change History

Changed 2 years ago by was

Changed 2 years ago by was

  • summary changed from notebook -- worksheet should call sys.path.append(DATA) when being initalized to [with patch; needs review] notebook -- worksheet should call sys.path.append(DATA) when being initalized

Changed 2 years ago by TimothyClemans

  • summary changed from [with patch; needs review] notebook -- worksheet should call sys.path.append(DATA) when being initalized to [with patch; needs work] notebook -- worksheet should call sys.path.append(DATA) when being initalized

When I attached hi.py, "import hi" didn't work. Also on  http://sage.math.washington.edu:8999/home/admin/3/datafile?name=hi.py, there is no mention of this new functionality.

Changed 10 months ago by was

  • status changed from needs_work to needs_review
  • summary changed from [with patch; needs work] notebook -- worksheet should call sys.path.append(DATA) when being initalized to [with patch; needs review] notebook -- worksheet should call sys.path.append(DATA) when being initalized

I've attached a totally new patch that is 1-line, works, and does the right thing, and is imho quite nice.

I still don't have my computer setup for Selenium, but a test this works is to do this in the notebook:

DATA in sys.path
///
True

Changed 10 months ago by was

apply only this -- ignore the old sage-3844.patch

Changed 9 months ago by timdumol

  • status changed from needs_review to needs_work
  • upstream set to N/A

I've come across the same problem as TimothyClemans? -- importing it after attachment does not work. Also, it would probably be best to advertise the functionality on the data page, as TimothyClemans? stated.

Changed 7 months ago by mpatel

Updates tutorial.py. Replaces previous.

Changed 7 months ago by mpatel

  • status changed from needs_work to needs_review
  • reviewer set to Mitesh Patel
  • summary changed from [with patch; needs review] notebook -- worksheet should call sys.path.append(DATA) when being initalized to notebook -- worksheet should call sys.path.append(DATA) when being initalized
  • author set to William Stein

This works for me -- After I upload a data file foo.py (or create a new one), I can import foo in a worksheet cell.

Positive review. V2 just adds the changes to tutorial.py from the original patch.

A load / attach analogue of sys.path might be warmly-received: #378, #1484, #5169.

By the way, FF 3.6 will permit drag-and-drop file uploads. See  this blog post for a video and simple demo.

Changed 7 months ago by mpatel

  • status changed from needs_review to positive_review

Changed 7 months ago by mpatel

Rebased for SageNB 0.6 + queue in comment. Replaces previous.

Changed 7 months ago by mpatel

  • status changed from positive_review to closed
  • resolution set to fixed
  • merged set to sagenb-0.7

Changed 7 months ago by mpatel

V3 is rebased for this queue:

sagenb-0.6
trac_7249-jinja2_v9.5.patch
trac_7962-link-worksheets-zip-file.patch
trac_7969-escaped-backslash.patch
trac_4217-html-system-formatting.3.patch
trac_3083-print-documentation.5.patch
trac_6182-double-quotes-ws.2.patch
trac_5263-publish-url.patch
trac_7631-republish-name.patch
trac_6353-cookies-diff-ports.patch
trac_7207-sagenb-future-import.3.patch
trac_8000-utf-8-coding-directive.2.patch
trac_4450-cursor-wrap-last-cell.patch
trac_7848-misleading_HTML_cells.patch
trac_7963-download-multiple-worksheets.patch
trac_7752-delete-worksheet-quit.patch
trac_7996-invisible_text.patch
trac_6475-error-delete-data-file.patch
trac_5675-address-launch.patch
trac_7435-dir-var.patch
trac_3844-DATA_in_sys_path.2.patch

Patch versions may be off by one.

Note: See TracTickets for help on using tickets.