Skip to content

Commit ec565d1

Browse files
authored
Version bump to 0.3.0 (#419)
* Extend collection test to validate member item URI (#398) * Adding DELETE operation to drone collection * English typos * Maintaining examples synchronized * Add crud test for nested objects and refactor other tests (#399) * Use HydraStatus and HydraError to return status response * Add a helper function to apply filtering. * Add helper function to create IriTemplates. * Use iri_template generator and attach generated iri_template to the colection response. * Implement searching * Add support for pagination of search results. * Add function to include mappings for properties of nested classes in IriTemplate * Add support for search over nested property values * Add tests for IriTemplates generated by hydrus. * Add test for searching mechanism(get_collection()) * Refactor by adding functions for parameter parsing and calculating page limit and offset * Refactor code by removing redundant check based on value of path variable * Add exception handling for invalid parameters * Add mechanism to support client-controlled pagination (#409) * Add helper function to attach pagination related mappings to the IriTemplate * Add an exception to handle incomaptible parameters * Add mechanism to handle client-guided pagination * Refactor code and add exception for out of range offset value. * Add tests for client controlled pagination. * Debug test_pep8.py and make codebase pep8 compatible. * Update hydrus with latest changes made at core (#411) * Update hydrus to use updated core and adapt code accordingly. * Update tests and add test for readable properties. * Bump version to 0.2.6 * Refactor crud.insert and create new file for other helper functions. * Add basic socket connection functionality to hydrus. * Add socketio update event for synchronization. * Add an endpoint for modification-table-diff. * Refactor some code and add inline comments. * Rename new_job_id field in response to job_id. * Add support to propagate multiple_delete modifications. * Add sync functionality for PUT and refactor code. * Add a thread to do routine cleanup of modification records. * Refactor 'modification-table endpoint' code. * Add tests for sync updates and modification-table. * Send an empty response with status-code 204 for outdated clients. * Use socketio event to send modification-table-diff. * Add reconnect event and extend tests. * Refactor and add comments. * Remove uuid and timestamp, and use incremental ids instead. * Use incremental job_id instead of timestamp to clean stale records. * Remove unused imports. * Use HydraLink to improve handling of nested object props. * Add links as GraphIII triples instead of GraphIIT triples. * Add link_prop to assist insertion of linked properties as GraphIII. * Adapt test for nested fields defined with hydra:Link. * Refactor insertion of GraphIII triples for link properties. * Add explicit type check for link properties. * Use latest hydra-python-core from the master branch. * Version bump to 0.3.0 * Update hydra-python-core branch to master
1 parent de2ae1e commit ec565d1

17 files changed

Lines changed: 1133 additions & 446 deletions

cli.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from sqlalchemy.orm import sessionmaker, scoped_session
33

44
from hydrus.app_factory import app_factory
5+
from hydrus.socketio_factory import create_socket
56
from hydrus.utils import (set_session, set_doc, set_hydrus_server_url,
67
set_token, set_api_name, set_authentication,
78
set_page_size, set_pagination)
@@ -10,6 +11,7 @@
1011
from hydrus.data.db_models import Base
1112
from hydrus.data.user import add_user
1213
from hydrus.data.exceptions import UserExists
14+
from hydrus.data.stale_records_cleanup import remove_stale_modification_records
1315
from gevent.pywsgi import WSGIServer
1416
from hydra_openapi_parser.openapi_parser import parse
1517
from hydrus.samples.hydra_doc_sample import doc as api_document
@@ -27,7 +29,7 @@
2729
help="The API name.", type=str)
2830
@click.option("--auth/--no-auth", default=True,
2931
help="Set authentication to True or False.")
30-
@click.option("--dburl", default="sqlite:///:memory:",
32+
@click.option("--dburl", default="sqlite:///database.db",
3133
help="Set database url", type=str)
3234
@click.option("--hydradoc", "-d", default=None,
3335
help="Location to HydraDocumentation (JSON-LD) of server.",
@@ -42,10 +44,13 @@
4244
help="Toggle token based user authentication.")
4345
@click.option("--serverurl", default="http://localhost",
4446
help="Set server url", type=str)
47+
@click.option("--stale_records_removal_interval", default=900,
48+
help="Interval period between removal of stale modification records.",
49+
type=int)
4550
@click.argument("serve", required=True)
4651
def startserver(adduser: Tuple, api: str, auth: bool, dburl: str, pagination: bool,
4752
hydradoc: str, port: int, pagesize: int, serverurl: str, token: bool,
48-
serve: None) -> None:
53+
stale_records_removal_interval: int, serve: None) -> None:
4954
"""
5055
Python Hydrus CLI
5156
@@ -82,8 +87,8 @@ def startserver(adduser: Tuple, api: str, auth: bool, dburl: str, pagination: bo
8287

8388
click.echo("Setting up the database")
8489
# Create a connection to the database you want to use
85-
engine = create_engine(DB_URL)
86-
90+
engine = create_engine(DB_URL, connect_args={'check_same_thread': False})
91+
Base.metadata.drop_all(engine)
8792
click.echo("Creating models")
8893
# Add the required Models to the database
8994
Base.metadata.create_all(engine)
@@ -159,6 +164,8 @@ def startserver(adduser: Tuple, api: str, auth: bool, dburl: str, pagination: bo
159164
# Create a Hydrus app with the API name you want, default will be "api"
160165
app = app_factory(API_NAME)
161166
# Set the name of the API
167+
# Create a socket for the app
168+
socketio = create_socket(app, session)
162169
click.echo("Starting the application")
163170
with set_authentication(app, auth):
164171
# Use authentication for all requests
@@ -174,17 +181,17 @@ def startserver(adduser: Tuple, api: str, auth: bool, dburl: str, pagination: bo
174181
with set_pagination(app, pagination):
175182
# Set page size of a collection view
176183
with set_page_size(app, pagesize):
184+
# Run a thread to remove stale modification records at some
185+
# interval of time.
186+
remove_stale_modification_records(
187+
session, stale_records_removal_interval)
177188
# Start the hydrus app
178-
http_server = WSGIServer(('', port), app)
189+
socketio.run(app, port=port)
179190
click.echo("Server running at:")
180191
click.echo(
181192
"{}{}".format(
182193
HYDRUS_SERVER_URL,
183194
API_NAME))
184-
try:
185-
http_server.serve_forever()
186-
except KeyboardInterrupt:
187-
pass
188195

189196

190197
if __name__ == "__main__":

0 commit comments

Comments
 (0)