Comments (7)
@dleen I think the simplest way would be to allow users to configure what events a FIM listens to. That way, you can disable the FIM from listening to delete
events from the CM, call get_id(<path>)
and delete the associated commenting data, and then call FIM.delete()
yourself (since all event listeners are public methods anyways).
This would be a pretty simple change to implement, do you want to give it a try? We use traitlets.config
to implement configurability of our classes. You would want to define a new trait that accepts a list that defines the CM event actions the class will listen to, say self.cm_actions
. This trait should default to listening to all the actions, e.g. default to the value ["get", "save", "rename", "copy", "delete"]
. Then, you would want to change the logic of the below method to bind the action to None
if the action isn't listed in self.cm_actions
.
def get_handlers_by_action(self) -> Dict[str, Optional[Callable[[Dict[str, Any]], Any]]]:
return {
"get": None,
"save": lambda data: self.save(data["path"]),
"rename": lambda data: self.move(data["source_path"], data["path"]),
"copy": lambda data: self.copy(data["source_path"], data["path"]),
"delete": lambda data: self.delete(data["path"]),
}
from jupyter_server_fileid.
Specifically tuning FIM's event listener works fine if your application is the only server extension in town. However, if other server extensions expect, in this case, "delete" events, they'll be screwed.
Seems like @dleen's suggestion of FIM emitting events (index
, move
, delete
, copy
?) and letting each server extension determine which events are pertinent is a good way to go. This eliminates the ambiguity of which listener acts first on the same event and doesn't interfere with multiple server extension configurations.
from jupyter_server_fileid.
@kevin-bates I'm not quite sure I follow. Dependent extensions need to be able to query for the file ID before the FIM deletes the record, not before. Emitting an event in the FIM methods to allow extensions to respond after deletion doesn't seem to solve @dleen 's issue.
from jupyter_server_fileid.
The deletion event would include the ID of the file deleted which would probably work
from jupyter_server_fileid.
Correct. All you (@dleen) need is the ID. This way the ambiguity is resolved. All events emitted by the FIM would include the corresponding ID(s).
from jupyter_server_fileid.
Ah, thank you both for clarifying. Then yes, we could implement support for this.
(btw I'm insanely busy with Jupyter AI, so I'd love to accept open source contributions for any of the issues opened recently, just reach out to me so I can assign you 🤗)
from jupyter_server_fileid.
Yes I'm willing to work on these issues - just wanted to discuss before jumping into the code
from jupyter_server_fileid.
Related Issues (20)
- prefix contents manager root to paths stored in ArbitraryFileIdManager HOT 1
- make `BaseFileIdManager` a true ABC
- Improve documentation about getting a LocalFileIdManager HOT 2
- support crtime on ext4
- remove mtime fallback HOT 4
- ArbitraryFileIdManager should have a configurable option to determine its "content root" HOT 3
- pypy compatibility
- Alternative file ID implementation
- create SQLite mixin
- jupyter-fileid script needs click HOT 6
- Tests are failing on archs like ppc64le or s390x HOT 5
- tmpfs support HOT 12
- Using sqlite in WAL mode causes file saving failure when used on JupyterHub on NFS HOT 15
- UNIQUE constraint failed when moving file HOT 9
- use a decorator to automatically commit after public methods
- Newly created notebook is not indexed HOT 5
- Allow db_path to be set to ":memory:" HOT 3
- Add simple REST API to fetch a file ID given a file path HOT 1
- Setup Github publishing actions and PyPI with Jupyter Server Bot.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jupyter_server_fileid.