Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

536 lines
25 KiB

  1. ;;; ein-contents-api.el --- Interface to Jupyter's Contents API -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2015 - John Miller
  3. ;; Authors: Takafumi Arakaki <aka.tkf at gmail.com>
  4. ;; John M. Miller <millejoh at mac.com>
  5. ;; This file is NOT part of GNU Emacs.
  6. ;; ein-contents-api.el is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; ein-contents-api.el is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with ein-notebooklist.el. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;;
  18. ;;; An interface to the Jupyter Contents API as described in
  19. ;;; https://github.com/ipython/ipython/wiki/IPEP-27%3A-Contents-Service.
  20. ;;;
  21. ;;
  22. ;;; Code:
  23. (require 'ein-core)
  24. (require 'ein-classes)
  25. (require 'ein-utils)
  26. (require 'ein-log)
  27. (require 'ein-query)
  28. (provide 'ein-notebook) ; see manual "Named Features" regarding recursive requires
  29. (require 'ein-notebook)
  30. (defcustom ein:content-query-max-depth 2
  31. "Don't recurse the directory tree deeper than this."
  32. :type 'integer
  33. :group 'ein)
  34. (defcustom ein:content-query-max-branch 6
  35. "Don't descend into more than this number of directories per depth. The total number of parallel queries should therefore be O({max_branch}^{max_depth})"
  36. :type 'integer
  37. :group 'ein)
  38. (defcustom ein:content-query-timeout nil ; (* 60 1000) ;1 min
  39. "Query timeout for getting content from Jupyter/IPython notebook.
  40. If you cannot open large notebooks because of a timeout error try
  41. increasing this value. Setting this value to `nil' means to use
  42. global setting. For global setting and more information, see
  43. `ein:query-timeout'."
  44. :type '(choice (integer :tag "Timeout [ms]" 5000)
  45. (const :tag "Use global setting" nil))
  46. :group 'ein)
  47. (defcustom ein:force-sync nil
  48. "If T, force ein to communicate with the IPython/Jupyter contents API synchronously. If not, use asynchronous communication. If you are seeing odd errors while using ein try setting this to T, though note that Emacs will likely be less responsive as it blocks while waiting for the IPython/Jupyter notebook server to respond"
  49. :type 'boolean
  50. :group 'ein)
  51. (defun ein:content-url (content &rest params)
  52. (apply #'ein:content-url* (ein:$content-url-or-port content) (ein:$content-path content) params))
  53. (defun ein:content-url* (url-or-port path &rest params)
  54. (let* ((which (if (< (ein:notebook-version-numeric url-or-port) 3)
  55. "notebooks" "contents"))
  56. (api-path (concat "api/" which)))
  57. (url-encode-url (apply #'ein:url
  58. url-or-port
  59. api-path
  60. path
  61. params))))
  62. (defun ein:content-query-contents (url-or-port path callback errback &optional iteration)
  63. "Register CALLBACK of arity 1 for the contents at PATH from the URL-OR-PORT. ERRBACK of arity 1 for the contents."
  64. (unless iteration
  65. (setq iteration 0))
  66. (ein:query-singleton-ajax
  67. (list 'content-query-contents url-or-port path)
  68. (ein:content-url* url-or-port path)
  69. :type "GET"
  70. :timeout ein:content-query-timeout
  71. :parser #'ein:json-read
  72. :sync ein:force-sync
  73. :complete (apply-partially #'ein:content-query-contents--complete url-or-port path)
  74. :success (apply-partially #'ein:content-query-contents--success url-or-port path callback)
  75. :error (apply-partially #'ein:content-query-contents--error url-or-port path callback errback iteration)))
  76. (cl-defun ein:content-query-contents--complete (_url-or-port _path
  77. &key data _symbol-status response
  78. &allow-other-keys
  79. &aux (resp-string (format "STATUS: %s DATA: %s" (request-response-status-code response) data)))
  80. (ein:log 'debug "ein:query-contents--complete %s" resp-string))
  81. (cl-defun ein:content-query-contents--error (url-or-port path callback errback iteration
  82. &key symbol-status response error-thrown data &allow-other-keys)
  83. (let ((status-code (request-response-status-code response))) ; may be nil!
  84. (cl-case status-code
  85. (404 (ein:log 'error "ein:content-query-contents--error %s %s"
  86. status-code (plist-get data :message))
  87. (when errback (funcall errback url-or-port status-code)))
  88. (t (if (< iteration (if noninteractive 6 3))
  89. (progn
  90. (ein:log 'verbose "Retry content-query-contents #%s in response to %s" iteration status-code)
  91. (sleep-for 0 (* (1+ iteration) 500))
  92. (ein:content-query-contents url-or-port path callback errback (1+ iteration)))
  93. (let ((notice
  94. (format "ein:content-query-contents--error %s REQUEST-STATUS %s DATA %s"
  95. (concat (file-name-as-directory url-or-port) path)
  96. symbol-status (cdr error-thrown))))
  97. (if (and (eql status-code 403) noninteractive)
  98. (progn
  99. (ein:log 'info notice)
  100. (when callback
  101. (funcall callback (ein:new-content url-or-port path data))))
  102. (ein:log 'error notice)
  103. (when errback (funcall errback url-or-port status-code)))))))))
  104. ;; TODO: This is one place to check for redirects - update the url slot if so.
  105. ;; Will need to pass the response object and check either request-response-history
  106. ;; or request-response-url.
  107. (cl-defun ein:content-query-contents--success (url-or-port path callback
  108. &key data _symbol-status response &allow-other-keys)
  109. (let (content)
  110. (if (< (ein:notebook-version-numeric url-or-port) 3)
  111. (setq content (ein:new-content-legacy url-or-port path data))
  112. (setq content (ein:new-content url-or-port path data)))
  113. (if (and response
  114. (> (length (request-response-history response)) 0))
  115. (setf (ein:$content-url-or-port content) (ein:get-response-redirect response)))
  116. (when callback
  117. (funcall callback content))))
  118. (defun ein:fix-legacy-content-data (data)
  119. (if (listp (car data))
  120. (cl-loop for item in data
  121. collecting
  122. (ein:fix-legacy-content-data item))
  123. (if (string= (plist-get data :path) "")
  124. (plist-put data :path (plist-get data :name))
  125. (plist-put data :path (format "%s/%s" (plist-get data :path) (plist-get data :name))))))
  126. (defun ein:content-to-json (content)
  127. (let ((path (if (>= (ein:$content-notebook-version content) 3)
  128. (ein:$content-path content)
  129. (substring (ein:$content-path content)
  130. 0
  131. (or (cl-position ?/ (ein:$content-path content) :from-end t)
  132. 0)))))
  133. (json-encode `((:type . ,(ein:$content-type content))
  134. (:name . ,(ein:$content-name content))
  135. (:path . ,path)
  136. (:format . ,(or (ein:$content-format content) "json"))
  137. (:content ,@(ein:$content-raw-content content))))))
  138. (defun ein:content-from-notebook (nb)
  139. (let ((nb-content (ein:notebook-to-json nb)))
  140. (make-ein:$content :name (ein:$notebook-notebook-name nb)
  141. :path (ein:$notebook-notebook-path nb)
  142. :url-or-port (ein:$notebook-url-or-port nb)
  143. :type "notebook"
  144. :notebook-version (ein:$notebook-api-version nb)
  145. :raw-content nb-content)))
  146. ;;; Managing/listing the content hierarchy
  147. (defvar *ein:content-hierarchy* (make-hash-table :test #'equal)
  148. "Content tree keyed by URL-OR-PORT.")
  149. (defun ein:content-need-hierarchy (url-or-port)
  150. "Callers assume ein:content-query-hierarchy succeeded. If not, nil."
  151. (ein:aif (gethash url-or-port *ein:content-hierarchy*) it
  152. (ein:log 'warn "No recorded content hierarchy for %s" url-or-port)
  153. nil))
  154. (defun ein:new-content-legacy (url-or-port path data)
  155. "Content API in 2.x a bit inconsistent."
  156. (if (plist-get data :type)
  157. (ein:new-content url-or-port path data)
  158. (let ((content (make-ein:$content
  159. :url-or-port url-or-port
  160. :notebook-version (ein:notebook-version-numeric url-or-port)
  161. :path path)))
  162. (setf (ein:$content-name content) (substring path (or (cl-position ?/ path) 0))
  163. (ein:$content-path content) path
  164. (ein:$content-type content) "directory"
  165. ;;(ein:$content-created content) (plist-get data :created)
  166. ;;(ein:$content-last-modified content) (plist-get data :last_modified)
  167. (ein:$content-format content) nil
  168. (ein:$content-writable content) nil
  169. (ein:$content-mimetype content) nil
  170. (ein:$content-raw-content content) (ein:fix-legacy-content-data data))
  171. content)))
  172. (defun ein:new-content (url-or-port path data)
  173. ;; data is like (:size 72 :content nil :writable t :path Untitled7.ipynb :name Untitled7.ipynb :type notebook)
  174. (let ((content (make-ein:$content
  175. :url-or-port url-or-port
  176. :notebook-version (ein:notebook-version-numeric url-or-port)
  177. :path path)))
  178. (setf (ein:$content-name content) (plist-get data :name)
  179. (ein:$content-path content) (plist-get data :path)
  180. (ein:$content-type content) (plist-get data :type)
  181. (ein:$content-created content) (plist-get data :created)
  182. (ein:$content-last-modified content) (plist-get data :last_modified)
  183. (ein:$content-format content) (plist-get data :format)
  184. (ein:$content-writable content) (plist-get data :writable)
  185. (ein:$content-mimetype content) (plist-get data :mimetype)
  186. (ein:$content-raw-content content) (plist-get data :content))
  187. content))
  188. (defun ein:content-query-hierarchy* (url-or-port path callback sessions depth content)
  189. "Returns list (tree) of content objects. CALLBACK accepts tree."
  190. (let* ((url-or-port url-or-port)
  191. (path path)
  192. (callback callback)
  193. (items (ein:$content-raw-content content))
  194. (directories (if (< depth ein:content-query-max-depth)
  195. (cl-loop for item in items
  196. with result = nil
  197. until (>= (length result) ein:content-query-max-branch)
  198. do (if (string= "directory" (plist-get item :type))
  199. (setf result (append result (list (ein:new-content url-or-port path item)))))
  200. finally return result ) ))
  201. (others (cl-loop for item in items
  202. with c0
  203. if (not (string= "directory" (plist-get item :type)))
  204. do (setf c0 (ein:new-content url-or-port path item)
  205. (ein:$content-session-p c0)
  206. (gethash (ein:$content-path c0) sessions))
  207. and collect c0
  208. end)))
  209. (deferred:$
  210. (apply #'deferred:parallel
  211. (cl-loop for c0 in directories
  212. collect
  213. (let ((c0 c0)
  214. (d0 (deferred:new #'identity)))
  215. (ein:content-query-contents
  216. url-or-port
  217. (ein:$content-path c0)
  218. (apply-partially #'ein:content-query-hierarchy*
  219. url-or-port
  220. (ein:$content-path c0)
  221. (lambda (tree)
  222. (deferred:callback-post d0 (cons c0 tree)))
  223. sessions (1+ depth))
  224. (lambda (&rest _ignore) (deferred:callback-post d0 (cons c0 nil))))
  225. d0)))
  226. (deferred:nextc it
  227. (lambda (tree)
  228. (let ((result (append others tree)))
  229. (when (string= path "")
  230. (setf (gethash url-or-port *ein:content-hierarchy*) (-flatten result)))
  231. (funcall callback result)))))))
  232. (defun ein:content-query-hierarchy (url-or-port callback)
  233. "Send for content hierarchy of URL-OR-PORT with CALLBACK arity 1 for content hierarchy"
  234. (ein:content-query-sessions
  235. url-or-port
  236. (apply-partially (lambda (url-or-port* callback* sessions)
  237. (ein:content-query-contents url-or-port* ""
  238. (apply-partially #'ein:content-query-hierarchy*
  239. url-or-port*
  240. ""
  241. callback* sessions 0)
  242. (lambda (&rest _ignore)
  243. (when callback* (funcall callback* nil)))))
  244. url-or-port callback)
  245. callback))
  246. ;;; Save Content
  247. (defun ein:content-save-legacy (content &optional callback cbargs errcb errcbargs)
  248. (ein:query-singleton-ajax
  249. (list 'content-save (ein:$content-url-or-port content) (ein:$content-path content))
  250. (ein:content-url content)
  251. :type "PUT"
  252. :headers '(("Content-Type" . "application/json"))
  253. :timeout ein:content-query-timeout
  254. :data (ein:content-to-json content)
  255. :success (apply-partially #'ein:content-save-success callback cbargs)
  256. :error (apply-partially #'ein:content-save-error (ein:content-url content) errcb errcbargs)))
  257. (defun ein:content-save (content &optional callback cbargs errcb errcbargs)
  258. (if (>= (ein:$content-notebook-version content) 3)
  259. (ein:query-singleton-ajax
  260. (list 'content-save (ein:$content-url-or-port content) (ein:$content-path content))
  261. (ein:content-url content)
  262. :type "PUT"
  263. :headers '(("Content-Type" . "application/json"))
  264. :timeout ein:content-query-timeout
  265. :data (encode-coding-string (ein:content-to-json content) buffer-file-coding-system)
  266. :success (apply-partially #'ein:content-save-success callback cbargs)
  267. :error (apply-partially #'ein:content-save-error (ein:content-url content) errcb errcbargs))
  268. (ein:content-save-legacy content callback cbargs)))
  269. (cl-defun ein:content-save-success (callback cbargs &key _status _response &allow-other-keys)
  270. ;;(ein:log 'verbose "Saving content successful with status %s" status)
  271. (when callback
  272. (apply callback cbargs)))
  273. (cl-defun ein:content-save-error (url errcb errcbargs &key response data &allow-other-keys)
  274. (ein:log 'error
  275. "Content save %s failed %s %s."
  276. url (request-response-error-thrown response) (plist-get data :message))
  277. (when errcb
  278. (apply errcb errcbargs)))
  279. ;;; Rename Content
  280. (defun ein:content-legacy-rename (content new-path callback cbargs)
  281. (let ((path (substring new-path 0 (or (position ?/ new-path :from-end t) 0)))
  282. (name (substring new-path (or (position ?/ new-path :from-end t) 0))))
  283. (ein:query-singleton-ajax
  284. (list 'content-rename (ein:$content-url-or-port content) (ein:$content-path content))
  285. (ein:content-url content)
  286. :type "PATCH"
  287. :data (json-encode `((name . ,name)
  288. (path . ,path)))
  289. :parser #'ein:json-read
  290. :success (apply-partially #'update-content-path-legacy content callback cbargs)
  291. :error (apply-partially #'ein:content-rename-error new-path))))
  292. (cl-defun update-content-path-legacy (content callback cbargs &key data &allow-other-keys)
  293. (setf (ein:$content-path content) (ein:trim-left (format "%s/%s" (plist-get data :path) (plist-get data :name))
  294. "/")
  295. (ein:$content-name content) (plist-get data :name)
  296. (ein:$content-last-modified content) (plist-get data :last_modified))
  297. (when callback
  298. (apply callback cbargs)))
  299. (defun ein:content-rename (content new-path &optional callback cbargs)
  300. (if (>= (ein:$content-notebook-version content) 3)
  301. (ein:query-singleton-ajax
  302. (list 'content-rename (ein:$content-url-or-port content) (ein:$content-path content))
  303. (ein:content-url content)
  304. :type "PATCH"
  305. :data (json-encode `((path . ,new-path)))
  306. :parser #'ein:json-read
  307. :success (apply-partially #'update-content-path content callback cbargs)
  308. :error (apply-partially #'ein:content-rename-error (ein:$content-path content)))
  309. (ein:content-legacy-rename content new-path callback cbargs)))
  310. (defun ein:session-rename (url-or-port session-id new-path)
  311. (ein:query-singleton-ajax
  312. (list 'session-rename session-id new-path)
  313. (ein:url url-or-port "api/sessions" session-id)
  314. :type "PATCH"
  315. :data (json-encode `((path . ,new-path)))
  316. :complete #'ein:session-rename--complete))
  317. (cl-defun ein:session-rename--complete (&key data response _symbol-status
  318. &allow-other-keys
  319. &aux (resp-string (format "STATUS: %s DATA: %s" (request-response-status-code response) data)))
  320. (ein:log 'debug "ein:session-rename--complete %s" resp-string))
  321. (cl-defun update-content-path (content callback cbargs &key data &allow-other-keys)
  322. (setf (ein:$content-path content) (plist-get data :path)
  323. (ein:$content-name content) (plist-get data :name)
  324. (ein:$content-last-modified content) (plist-get data :last_modified))
  325. (when callback
  326. (apply callback cbargs)))
  327. (cl-defun ein:content-rename-error (path &key response data &allow-other-keys)
  328. (ein:log 'error
  329. "Renaming content %s failed %s %s."
  330. path (request-response-error-thrown response) (plist-get data :message)))
  331. ;;; Sessions
  332. (defun ein:content-query-sessions (url-or-port callback errback &optional iteration)
  333. "Register CALLBACK of arity 1 to retrieve the sessions. Call ERRBACK of arity 1 (contents) upon failure."
  334. (unless iteration
  335. (setq iteration 0))
  336. (unless callback
  337. (setq callback #'ignore))
  338. (unless errback
  339. (setq errback #'ignore))
  340. (ein:query-singleton-ajax
  341. (list 'content-query-sessions url-or-port)
  342. (ein:url url-or-port "api/sessions")
  343. :type "GET"
  344. :parser #'ein:json-read
  345. :complete (apply-partially #'ein:content-query-sessions--complete url-or-port callback)
  346. :success (apply-partially #'ein:content-query-sessions--success url-or-port callback)
  347. :error (apply-partially #'ein:content-query-sessions--error url-or-port callback errback iteration)
  348. :sync ein:force-sync))
  349. (cl-defun ein:content-query-sessions--success (url-or-port callback &key data &allow-other-keys)
  350. (cl-flet ((read-name (nb-json)
  351. (if (< (ein:notebook-version-numeric url-or-port) 3)
  352. (if (string= (plist-get nb-json :path) "")
  353. (plist-get nb-json :name)
  354. (format "%s/%s" (plist-get nb-json :path) (plist-get nb-json :name)))
  355. (plist-get nb-json :path))))
  356. (let ((session-hash (make-hash-table :test 'equal)))
  357. (dolist (s data (funcall callback session-hash))
  358. (setf (gethash (read-name (plist-get s :notebook)) session-hash)
  359. (cons (plist-get s :id) (plist-get s :kernel)))))))
  360. (cl-defun ein:content-query-sessions--error (url-or-port callback errback iteration
  361. &key response error-thrown &allow-other-keys)
  362. (if (< iteration (if noninteractive 6 3))
  363. (progn
  364. (ein:log 'verbose "Retry sessions #%s in response to %s" iteration (request-response-status-code response))
  365. (sleep-for 0 (* (1+ iteration) 500))
  366. (ein:content-query-sessions url-or-port callback errback (1+ iteration)))
  367. (ein:log 'error "ein:content-query-sessions--error %s: ERROR %s DATA %s" url-or-port (car error-thrown) (cdr error-thrown))
  368. (when errback (funcall errback nil))))
  369. (cl-defun ein:content-query-sessions--complete (_url-or-port _callback
  370. &key data response &allow-other-keys
  371. &aux (resp-string (format "STATUS: %s DATA: %s" (request-response-status-code response) data)))
  372. (ein:log 'debug "ein:query-sessions--complete %s" resp-string))
  373. ;;; Checkpoints
  374. (defun ein:content-query-checkpoints (content &optional callback cbargs)
  375. (let* ((url (ein:content-url content "checkpoints")))
  376. (ein:query-singleton-ajax
  377. (list 'content-query-checkpoints url)
  378. url
  379. :type "GET"
  380. :timeout ein:content-query-timeout
  381. :parser #'ein:json-read
  382. :sync ein:force-sync
  383. :success (apply-partially #'ein:content-query-checkpoints-success content callback cbargs)
  384. :error (apply-partially #'ein:content-query-checkpoints-error content))))
  385. (defun ein:content-create-checkpoint (content &optional callback cbargs)
  386. (let* ((url (ein:content-url content "checkpoints")))
  387. (ein:query-singleton-ajax
  388. (list 'content-query-checkpoints url)
  389. url
  390. :type "POST"
  391. :timeout ein:content-query-timeout
  392. :parser #'ein:json-read
  393. :sync ein:force-sync
  394. :success (apply-partially #'ein:content-query-checkpoints-success content callback cbargs)
  395. :error (apply-partially #'ein:content-query-checkpoints-error content))))
  396. (defun ein:content-restore-checkpoint (content checkpoint-id &optional callback cbargs)
  397. (let* ((url (ein:content-url content "checkpoints" checkpoint-id)))
  398. (ein:query-singleton-ajax
  399. (list 'content-query-checkpoints url)
  400. url
  401. :type "POST"
  402. :timeout ein:content-query-timeout
  403. :parser #'ein:json-read
  404. :sync ein:force-sync
  405. :success (when callback
  406. (apply callback cbargs))
  407. :error (apply-partially #'ein:content-query-checkpoints-error content))))
  408. (defun ein:content-delete-checkpoint (content checkpoint-id &optional callback cbargs)
  409. (let* ((url (ein:content-url content "checkpoints" checkpoint-id)))
  410. (ein:query-singleton-ajax
  411. (list 'content-query-checkpoints url)
  412. url
  413. :type "DELETE"
  414. :timeout ein:content-query-timeout
  415. :parser #'ein:json-read
  416. :sync ein:force-sync
  417. :success (when callback
  418. (apply callback cbargs))
  419. :error (apply-partially #'ein:content-query-checkpoints-error content))))
  420. (cl-defun ein:content-query-checkpoints-success (content cb cbargs &key data _status _response &allow-other-keys)
  421. (unless (listp (car data))
  422. (setq data (list data)))
  423. (setf (ein:$content-checkpoints content) data)
  424. (when cb
  425. (apply cb content cbargs)))
  426. (cl-defun ein:content-query-checkpoints-error (_content &key symbol-status response &allow-other-keys)
  427. (ein:log 'error "Content checkpoint operation failed with status %s (%s)." symbol-status response))
  428. ;;; Uploads
  429. (defun ein:get-local-file (path)
  430. "If path exists, get contents and try to guess type of file (one of file, notebook, or directory)
  431. and content format (one of json, text, or base64)."
  432. (unless (file-readable-p path)
  433. (error "File %s is not accessible and cannot be uploaded." path))
  434. (let ((name (file-name-nondirectory path))
  435. (type (file-name-extension path)))
  436. (with-temp-buffer
  437. (insert-file-contents path)
  438. (cond ((string= type "ipynb")
  439. (list name "notebook" "json" (buffer-string)))
  440. ((eql buffer-file-coding-system 'no-conversion)
  441. (list name "file" "base64" (buffer-string)))
  442. (t (list name "file" "text" (buffer-string)))))))
  443. (defun ein:content-upload (path uploaded-file-path &optional url-or-port)
  444. (cl-multiple-value-bind (name type format contents) (ein:get-local-file uploaded-file-path)
  445. (let* ((content (make-ein:$content :url-or-port (or url-or-port (ein:default-url-or-port))
  446. :name name
  447. :path (concat path "/" name)
  448. :raw-content contents))
  449. (data (make-hash-table)))
  450. (setf (gethash 'path data) path
  451. (gethash 'name data) name
  452. (gethash 'type data) type
  453. (gethash 'format data) format
  454. (gethash 'content data) contents)
  455. (ein:query-singleton-ajax
  456. (list 'content-upload name)
  457. (ein:content-url content)
  458. :type "PUT"
  459. :headers '(("Content-Type" . "application/json"))
  460. :timeout ein:content-query-timeout
  461. :data (json-encode data)
  462. :success (let ((uploaded-file-path uploaded-file-path))
  463. #'(lambda (&rest _ignore) (message "File %s succesfully uploaded." uploaded-file-path)))
  464. :error (apply-partially #'ein:content-upload-error uploaded-file-path)))))
  465. (cl-defun ein:content-upload-error (path &key symbol-status _response &allow-other-keys)
  466. (ein:display-warning (format "Could not upload %s. Failed with status %s" path symbol-status)))
  467. (provide 'ein-contents-api)