-
Notifications
You must be signed in to change notification settings - Fork 4
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
Re-architect backend tornado http server. Adds supporting decoupled library packages. (Large PR) #80
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…d some pydantic api models
…ds login url path to base handler
…hild classes that don't need this functionality
…ookie created post login is used to retain login state.
sblack-usu
reviewed
Aug 23, 2021
sblack-usu
reviewed
Aug 23, 2021
sblack-usu
reviewed
Aug 23, 2021
…extension_points is not _jupyter_server_extension_paths
…e type hint declarations. Previous imp, causes duplicate value fields, to be 'removed'
…he correct intermediate baggit like structure.
…ers issue in hsclient. See hsclient hydroshare#23.
…path where hydroshare resources are stored.
…ter sync data directory via a GET request. Does not require login
…s TODO action). When resource entity is downloaded, both local and remote resource are updated, meaning, at the resource level, all the md5 checksums are recomputed and the remote is re-queired for changes in the manifest-md5.txt file
… debug level logging for tx'd messages
aaraney
pushed a commit
that referenced
this pull request
Sep 27, 2021
…ctor and make #80's reviewer's lives easier.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Large backend change. In summary, all tornado http handlers have been re-written. Handlers now:
validate input and output using
pydantic
, usehsclient
to communicate with HydroShare whenrequired, enforce content-type headers, send meaningful http response codes, and rely on an
encrypted session cookie to validate and maintain login status. Filesystem state responsibility has
also been changes, now, a websocket handler pushes local HydroShare resource filesystem status
updates to the client.
Additions
handlers
subpackage. WIP. In future, tornado handlers now inserver.py
will be modularized and move here. Currently, theget_route_handlers
method is the only thing that has been ported fromserver.py
.lib
package added with following:filesystem
package:FSMap
&FSResourceMap
) that describe the relationships between hydroshare resources, resource files', and resource files' md5 checksum.FSResourceMap
: (RemoteFSResourceMap
&LocalFSResourceMap
are subclasses) encapsulate relationship between a single resource and the resource's files and file checksums.FSMap
: (RemoteFSMap
&LocalFSMap
are subclasses) encapsulate relationship between one or more resources andFSResourceMap
instances.AggregateFSMap
: Encapsulate aRemoteFSMap
&LocalFSMap
instance and treat them as if they were a single instance (updates both).events
package:resource_factories
:resource_strategies
resource_factories
watchdog
added as dependency. It is used to watch filesystem changes and relay those changes to a client via a websocket connection.utilities
subpackage. Addspathlib
utilities to simplify common multi-step operations.models
subpackage. Housespydantic
models used in software. Used by handlers to validate and marshal http handler inputs and outputs.templates
subpackage. Housestornado
html templates used in software.Removals
Changes
~/.config/hydroshare_jupyter_sync/config
,~/.hydroshare_jupyter_sync_config
. Currently supported config keys areDATA
andLOG
.HeadersMixIn
overridesset_default_headers
in child classes. Child classes provide a tuple collection of header value pairs in a class variable,_custom_headers
field.SessionMixIn
adds methods for reading session and interacting with session state. (i.e. get thehsclient.HydroShare
for the current session.)MutateSessionMixIn
adds method to mutate (reset or replace w/ new instance) the global session struct object (containshsclient.HydroShare
session, session cookie, userid
and username).user
). This cookie must be send along with each request to retrieve a <300 response.hsclient
is now used to sign-in and interact with HydroShare (check resource remote state, download, and upload resources)./syncApi/ws
: websocket over which local vs. remote filesystem state are pushed from the server to the client./syncApi/user
: get user info (name, email, url, phone, address, org, website, orcid, google scholar id, research gate id)./syncApi/resources
: collection of resources a user owns (resource type, title, id, is immutable, url, creation date, last modified date)./syncApi/resources/<resource-id>
: collection of files and file checksum in a resource owned by a user./syncApi/resources/<resource-id>/download
: download a resource owned by the user locally./syncApi/resources/<resource-id>/upload
: upload a local file or folder to an existing hydroshare resource./syncApi/resources/<resource-id>/download/<file-or-directory>?folder=(true | false)
: download a file or folder in a HydroShare resource owned by the user locally. Paths should be specified relative to/data/contents
(i.e. to download a file,f
in resource1
which is saved in the bagit store at1/1/data/contents/f
, onlyf
would be specified in the request).hydroshare_jupyter_sync
in develop mode now use CLI viapython -m hydroshare_jupyter_sync
. Allows changingport
number,hostname
, supplying an alternative config file, or disabling debug mode via CLI.Notes
If you are a reviewer of this massive PR, I would mainly pay attention to the following subpackages and modules (in order):
hydroshare_jupyter_sync/handlers/__init__.py
define handler endpointshydroshare_jupyter_sync/server.py
tornado http handlershydroshare_jupyter_sync/websocket_handler.py
tornado websocket handlerhydroshare_jupyter_sync/lib/
a few modularized library packageshydroshare_jupyter_sync/fs_events.py & fs_event_handler.py
hydroshare_jupyter_sync/session_struct.py
hydroshare_jupyter_sync/session.py
hydroshare_jupyter_sync/session_sync_event_listeners.py
hydroshare_jupyter_sync/utilities
There are several handlers, methods, and modules that were not removed in this PR. Most notably, many of the tornado handlers in
hydroshare_jupyter_sync/server.py
are no longer used (in the future they will be removed). I would suggest looking at theget_route_handlers
in thehandlers
(this method will also change in the future).Ignore changes to
hydroshare_jupyter_sync/resource_manager.py
, the module is no longer used in the project and the majority of changes are code reformatting done byblack
.Todos
handlers
subpackage.