Skip to content

Commit

Permalink
merge tim's main
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Jun 6, 2023
1 parent d1c4914 commit aeebe6f
Show file tree
Hide file tree
Showing 14 changed files with 9,950 additions and 8,199 deletions.
9 changes: 0 additions & 9 deletions .github/CODEOWNERS

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build: ## build python/javascript
python -m build .

develop: ## install to site-packages in editable mode
python -m pip install --upgrade build docker-compose "jupyterlab>=3.5,<4" pip setuptools twine wheel
python -m pip install --upgrade build docker-compose jupyterlab pip setuptools twine wheel
python -m pip install -vvv .[develop]

install: ## install to site-packages
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<p align="center">
<img alt="jupyter-fs" src="https://raw.githubusercontent.com/jpmorganchase/jupyter-fs/main/docs/brand-icon.svg" width="400">
<img alt="jupyter-fs" src="https://raw.githubusercontent.com/timkpaine/jupyter-fs/main/docs/brand-icon.svg" width="400">
</p>

#

<p>
<a href="https://dev.azure.com/tpaine154/jupyter/_apis/build/status/jpmorganchase.jupyter-fs?branchName=main"><img alt="azure ci status" src="https://dev.azure.com/tpaine154/jupyter/_apis/build/status/jpmorganchase.jupyter-fs?branchName=main"></a>
<a href="https://ci.appveyor.com/project/telamonian/jupyter-fs/branch/main"><img alt="appveyor ci status (telamonian fork)" src="https://ci.appveyor.com/api/projects/status/d8flhw12vpvgime4/branch/main?svg=true"></a>
<a href="https://github.com/timkpaine/jupyter-fs/actions?query=workflow%3A%22Build+Status%22"><img alt="build status" src="https://github.com/timkpaine/jupyter-fs/workflows/Build%20Status/badge.svg?branch=main"></a>
<a href="https://pypi.python.org/pypi/jupyter-fs"><img alt="pypi package" src="https://img.shields.io/pypi/v/jupyter-fs.svg"></a>
<a href="https://www.npmjs.com/package/jupyter-fs"><img alt="npm package" src="https://img.shields.io/npm/v/jupyter-fs.svg"></a>
</p>
Expand Down Expand Up @@ -69,7 +68,7 @@ Add specifications for additional contents managers in your user settings (in th

You should see your new filebrowsers pop up in the left-hand sidebar instantly when you save your settings:

![](https://raw.githubusercontent.com/jpmorganchase/jupyter-fs/master/docs/osfs_example.png)
![](https://raw.githubusercontent.com/timkpaine/jupyter-fs/main/docs/osfs_example.png)


## Use with auth/credentials
Expand All @@ -91,7 +90,7 @@ Any stretch of a `"url"` that is enclosed in double-brackets `{{VAR}}` will be t

When you save the above `"resouces"` config, a dialog box will pop asking for the `username` and `passwd` values:

![](https://raw.githubusercontent.com/jpmorganchase/jupyter-fs/master/docs/remote_example.png)
![](https://raw.githubusercontent.com/timkpaine/jupyter-fs/main/docs/remote_example.png)

Once you enter those values and hit ok, the new filebrowsers will then immediately appear in the sidebar:

Expand Down Expand Up @@ -160,10 +159,10 @@ Any filesystem resources specified in any server-side config file will be merged

## Development

See [CONTRIBUTING.md](https://github.com/jpmorganchase/jupyter-fs/blob/master/CONTRIBUTING.md) for guidelines.
See [CONTRIBUTING.md](https://github.com/timkpaine/jupyter-fs/blob/main/CONTRIBUTING.md) for guidelines.


## License

This software is licensed under the Apache 2.0 license. See the
[LICENSE](https://github.com/jpmorganchase/jupyter-fs/blob/master/LICENSE) and [AUTHORS](https://github.com/jpmorganchase/jupyter-fs/blob/master/AUTHORS) files for details.
[LICENSE](https://github.com/timkpaine/jupyter-fs/blob/main/LICENSE) and [AUTHORS](https://github.com/timkpaine/jupyter-fs/blob/main/AUTHORS) files for details.
Empty file modified ci/mac/enable_sharing.sh
100644 → 100755
Empty file.
13 changes: 6 additions & 7 deletions js/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ module.exports = {
testPathIgnorePatterns: ["/lib/", "/node_modules/"],
testRegex: "tests\/.*\.test\.ts[x]?$", // eslint-disable-line no-useless-escape
transform: {
"\\.tsx?$": "ts-jest",
"\\.tsx?$": [
"ts-jest", {
// in tsconfig.test.json, rootDir is parent of both tests and src dirs
tsconfig: "tsconfig.test.json",
},
],
"\\.jsx?$": "babel-jest",
},
transformIgnorePatterns: [`node_modules/(?!(${esModules}))`],
globals: {
"ts-jest": {
// in tsconfig.test.json, rootDir is parent of both tests and src dirs
tsconfig: "tsconfig.test.json",
},
},
};
68 changes: 33 additions & 35 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"postpack": "shx rm README.md",
"prepack": "shx cp ../README.md .",
"prepublishOnly": "jlpm clean && jlpm clean:labextension && jlpm integrity && jlpm build:prod",
"test": "jest --coverage --collectCoverageFrom=src/*.{ts,tsx}",
"test": "jest --coverage",
"test:browser": "../ci/browser_check.sh",
"watch": "run-p watch:lib watch:labextension",
"watch:lib": "tsc -b -w",
Expand All @@ -41,62 +41,60 @@
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
],
"dependencies": {
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/docmanager": "^3.0.0",
"@jupyterlab/docregistry": "^3.0.0",
"@jupyterlab/filebrowser": "^3.0.0",
"@jupyterlab/services": "^6.0.0",
"@jupyterlab/settingregistry": "^3.0.0",
"@jupyterlab/statusbar": "^3.0.0",
"@jupyterlab/translation": "^3.0.0",
"@jupyterlab/ui-components": "^3.0.0",
"@lumino/algorithm": "^1.3.3",
"@lumino/commands": "^1.3.3",
"@lumino/disposable": "^1.4.3",
"@lumino/messaging": "^1.4.3",
"@lumino/signaling": "^1.4.3",
"@lumino/widgets": "^1.35.0",
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@jupyterlab/coreutils": "^6.0.0",
"@jupyterlab/docmanager": "^4.0.0",
"@jupyterlab/docregistry": "^4.0.0",
"@jupyterlab/filebrowser": "^4.0.0",
"@jupyterlab/services": "^7.0.0",
"@jupyterlab/settingregistry": "^4.0.0",
"@jupyterlab/statusbar": "^4.0.0",
"@jupyterlab/translation": "^4.0.0",
"@jupyterlab/ui-components": "^4.0.0",
"@lumino/algorithm": "^2.0.0",
"@lumino/commands": "^2.0.0",
"@lumino/disposable": "^2.1.1",
"@lumino/messaging": "^2.0.0",
"@lumino/signaling": "^2.0.0",
"@lumino/widgets": "^2.0.0",
"@material-ui/core": "^4.11.3",
"file-saver": "^2.0.5",
"jszip": "^3.7.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tree-finder": "^0.0.13"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.20.2",
"@jupyterlab/builder": "^3.0.0",
"@jupyterlab/builder": "^4.0.0",
"@types/file-saver": "^2.0.1",
"@types/jest": "^26.0.22",
"@types/jest": "^29.5.1",
"@types/jszip": "^3.4.1",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.29.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-jsdoc": "^44.2.4",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^45.0.1",
"eslint-plugin-unicorn": "^47.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^26",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "^16.0.0",
"jest-raw-loader": "^1.0.1",
"mkdirp": "^1.0.4",
"rimraf": "^3.0.2",
"mkdirp": "^3.0.1",
"rimraf": "^5.0.1",
"shx": "^0.3.3",
"source-map-loader": "^4.0.1",
"ts-jest": "^26.5.4",
"typescript": "^4.2.4",
"ts-jest": "^29.1.0",
"typescript": "^4.5.0",
"yarn-deduplicate": "^6.0.0"
},
"resolutions": {
"**/@types/react": "^17.0.0"
},
"sideEffects": [
"style/**/*.css",
"style/index.js"
Expand All @@ -113,7 +111,7 @@
}
}
},
"extension": true,
"extension": "lib/index.js",
"outputDir": "../jupyterfs/labextension",
"schemaDir": "schema"
}
Expand Down
12 changes: 7 additions & 5 deletions js/src/treefinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ToolbarButton,
WidgetTracker, /*Clipboard, Dialog, IWindowResolver, showDialog*/
} from "@jupyterlab/apputils";

// import { PathExt, URLExt } from "@jupyterlab/coreutils";
import { IDocumentManager, isValidFileName /*renameFile*/ } from "@jupyterlab/docmanager";
// import { DocumentRegistry } from "@jupyterlab/docregistry";
Expand Down Expand Up @@ -44,6 +45,7 @@ import { IFSResource } from "./filesystem";
import { fileTreeIcon } from "./icons";
import { promptRename } from "./utils";
import { Uploader, UploadButton } from "./upload";
import { ContentsManager } from "@jupyterlab/services";


export class TreeFinderTracker extends WidgetTracker<TreeFinderSidebar> {
Expand Down Expand Up @@ -91,7 +93,7 @@ export class TreeFinderWidget extends Widget {
super({ node });
this.addClass("jp-tree-finder");

this.contentsProxy = new ContentsProxy(contents, rootPath);
this.contentsProxy = new ContentsProxy(contents as ContentsManager, rootPath);

this.translator = translator || nullTranslator;
this._trans = this.translator.load("jupyterlab");
Expand Down Expand Up @@ -429,9 +431,9 @@ export class TreeFinderSidebar extends Widget {

this.treefinder = new TreeFinderWidget({ app, rootPath, columns });

this.layout = new PanelLayout();
this.layout.addWidget(this.toolbar);
this.layout.addWidget(this.treefinder);
this.panel_layout = new PanelLayout();
(this.panel_layout as PanelLayout).addWidget(this.toolbar);
(this.panel_layout as PanelLayout).addWidget(this.treefinder);
}

restore() { // restore expansion prior to rebuild
Expand Down Expand Up @@ -503,7 +505,7 @@ export class TreeFinderSidebar extends Widget {
toolbar: Toolbar;
treefinder: TreeFinderWidget;

readonly layout: PanelLayout;
readonly panel_layout: PanelLayout;
readonly url: string;
}

Expand Down
14 changes: 10 additions & 4 deletions jupyterfs/metamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
from hashlib import md5
import json
import re

from traitlets import default
from tornado import web

from fs.errors import FSError
from fs.opener.errors import OpenerError, ParseError
from jupyter_server.base.handlers import APIHandler
from jupyter_server.services.contents.manager import ContentsManager
from jupyter_server.services.contents.manager import AsyncContentsManager

from .auth import substituteAsk, substituteEnv, substituteNone
from .config import JupyterFs as JupyterFsConfig
Expand All @@ -31,9 +33,13 @@
__all__ = ["MetaManager", "MetaManagerHandler"]


class MetaManager(ContentsManager):
class MetaManager(AsyncContentsManager):
copy_pat = re.compile(r"\-Copy\d*\.")

@default("files_handler_params")
def _files_handler_params_default(self):
return {"path": self.root_dir}

def __init__(self, **kwargs):
super().__init__(**kwargs)
self._jupyterfsConfig = JupyterFsConfig(config=self.config)
Expand Down Expand Up @@ -144,7 +150,7 @@ def root_manager(self):
def root_dir(self):
return self.root_manager.root_dir

def copy(self, from_path, to_path=None):
async def copy(self, from_path, to_path=None):
"""Copy an existing file and return its new model.
If to_path not specified, it will be the parent directory of from_path.
Expand Down Expand Up @@ -207,7 +213,7 @@ def _getManagerForPath(self, path):
get = path_first_arg("get", True)
delete = path_first_arg("delete", False)

get_kernel_path = path_first_arg("get_kernel_path", False)
get_kernel_path = path_first_arg("get_kernel_path", False, sync=True)

create_checkpoint = path_first_arg("create_checkpoint", False)
list_checkpoints = path_first_arg("list_checkpoints", False)
Expand Down
28 changes: 19 additions & 9 deletions jupyterfs/pathutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,25 @@ def _get_arg(argname, args, kwargs):


# Dispatch decorators.
def path_first_arg(method_name, returns_model):
def path_first_arg(method_name, returns_model, sync=False):
"""Decorator for methods that accept path as a first argument,
e.g. manager.get(path, ...)"""

def _wrapper(self, *args, **kwargs):
path, args = _get_arg("path", args, kwargs)
_, mgr, mgr_path = _resolve_path(path, self._managers)
result = getattr(mgr, method_name)(mgr_path, *args, **kwargs)
return result
if sync:

def _wrapper(self, *args, **kwargs):
path, args = _get_arg("path", args, kwargs)
_, mgr, mgr_path = _resolve_path(path, self._managers)
result = getattr(mgr, method_name)(mgr_path, *args, **kwargs)
return result

else:

async def _wrapper(self, *args, **kwargs):
path, args = _get_arg("path", args, kwargs)
_, mgr, mgr_path = _resolve_path(path, self._managers)
result = getattr(mgr, method_name)(mgr_path, *args, **kwargs)
return result

return _wrapper

Expand All @@ -106,7 +116,7 @@ def path_second_arg(method_name, first_argname, returns_model):
"""Decorator for methods that accept path as a second argument.
e.g. manager.save(model, path, ...)"""

def _wrapper(self, *args, **kwargs):
async def _wrapper(self, *args, **kwargs):
other, args = _get_arg(first_argname, args, kwargs)
path, args = _get_arg("path", args, kwargs)
_, mgr, mgr_path = _resolve_path(path, self._managers)
Expand All @@ -123,7 +133,7 @@ def path_kwarg(method_name, path_default, returns_model):
e.g. manager.file_exists(path='')
"""

def _wrapper(self, path=path_default, **kwargs):
async def _wrapper(self, path=path_default, **kwargs):
_, mgr, mgr_path = _resolve_path(path, self._managers)
result = getattr(mgr, method_name)(path=mgr_path, **kwargs)
return result
Expand All @@ -137,7 +147,7 @@ def path_old_new(method_name, returns_model):
e.g. manager.rename(old_path, new_path)
"""

def _wrapper(self, old_path, new_path, *args, **kwargs):
async def _wrapper(self, old_path, new_path, *args, **kwargs):
old_prefix, old_mgr, old_mgr_path = _resolve_path(old_path, self._managers)
new_prefix, new_mgr, new_mgr_path = _resolve_path(new_path, self._managers)
if old_mgr is not new_mgr:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"private": true,
"license": "BSD-3-Clause",
"workspaces": ["js"],
"workspaces": [
"js"
],
"scripts": {
"develop": "jupyter labextension develop --overwrite .",
"test:browser": "jlpm --cwd ./js test:browser"
Expand Down
Loading

0 comments on commit aeebe6f

Please sign in to comment.