Skip to content
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

Version feature #388

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

jahandaniyal
Copy link
Collaborator

@jahandaniyal jahandaniyal commented Jun 9, 2018

Purpose

This patch implements Graph Version- Allow users to Create, Get, and Delete Graph Versions.

Feature Details

Version Control will be an important feature for GraphSpace, multiple versions of a Graph can be created
by a user and the user can switch between these versions using the GraphSpace Application or through REST APIs.
Currently Graph Version feature allows user to do the following operations on the Graph

  • Create a Graph Version

  • Get all versions of a particular Graph

  • Get a graph version by graph_version_id

  • Set a graph version as default version of the Graph

  • Delete a graph version

graph_version

Screenshot for Graph Version Tab

Approach

Major changes have been made in the Graph table to implement Graph Version feature.
The graph_json & style_json have been migrated to GraphVersion table. A column default_version_id has been added to Graph table, it stores the id of the default version of the graph. The Graph APIs have not been affected in a major way (default_version_id parameter has been added to link a graph to a particular version), however, the API is still backwards compatible with the previous format/parameters.

Creating Graph Version :
A graph version is created by default when a new graph is created.
Users can also create graph version for existing graphs. Currently, graph versions can only be added using the REST APIs.
Example,
POST : http://127.0.0.1:8000/api/v1/graphs/<graph_id>/version/ will create a new graph version for the graph with ID - graph_id. More information about REST API usage has been documented in api specifications

GET/read graph version :

When a Graph is opened, all the versions associated with that graph are fetched from the graph_version table.
Specific graph versions can also be fetched using graph_version_id
Example,
GET : http://127.0.0.1:8000/api/v1/graphs/<graph_id>/version?owner_email=<user_id> - Query all the versions of graph with id - graph_id.
GET : http://127.0.0.1:8000/api/v1/graphs/<graph_id>/version/<graph_version_id>?owner_email=<user_id> - Query graph version with ID - graph_version_id and graph ID - graph_id

Delete graph version:
Non-default graph versions can be deleted using GraphVersion REST API, however, to delete a default graph version a different version needs to be made default before deleting it.
Example,
DELETE : http://127.0.0.1:8000/api/v1/graphs/<graph_id>/version/<graph_version_id>?owner_email=<user_id> - This will delete graph version with ID graph_version_id for graph with id graph_id

Testing REST APIs & GraphSpace ajax requests :

Since, there were changes in the existing graph table - REST API for both Graph and GraphVersion have been tested.
Graph REST API Test :

  • Get all Graphs : Passed. Works as expected

  • Get graph by ID : Passed. Works as expected

  • Add a Graph : Passed. Works as expected

  • Delete a Graph : Passed. Works as expected. Deletes all graph versions for a particular graph also.

Graph Version REST API Test :

  • Get all version of a graph : Passed. Fetches all graph versions for a particular graph

  • Get specific version of a graph : Passed. Fetches graph version by ID or else returns None.

  • Add a version : Passed. Works as expected

  • Delete a graph version : User can delete any non-default graph version using the REST APIs. To delete the default graph version, user needs to set another version as the default. Deleting a graph will automatically remove all graph versions for that graph.

version_page_raml

View API RAML as HTML document

Open Questions and Pre-Merge TODOs

@jahandaniyal

  • PR documentation
    • Document API changes
    • Document UI changes (mainly GIFs and screenshots)
  • User documentation
  • API documentation in RAML
    • Add a screenshot of HTML docs generated from RAML here.
  • Developer documentation in Wiki
  • Python documentation in Code
  • Write tests in Python

Learning

http://gsoc18.blogspot.com/
Links to blog posts, patterns, libraries or addons used to solve this problem

Blog Posts

adbharadwaj and others added 4 commits March 3, 2018 20:36
Adding a pull request template to standardize the description of the proposed changes from contributors. Project contributors will automatically see the template's contents in the pull request body.

More details can be found [here](https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/).
else:
orber_by = db.asc(sort_attr)

## TODO: create a util function to relpace the code parse sort and order parameters. This code is repeated again and again.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are planning to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi.
I did not understand the question. Could you please elaborate.
Thanks

@@ -586,3 +586,39 @@ def add_edge(request, name=None, head_node_id=None, tail_node_id=None, is_direct
def delete_edge_by_id(request, edge_id):
db.delete_edge(request.db_session, id=edge_id)
return

def search_graph_versions(request, graph_id=None, names=None, limit=20, offset=0, order='desc', sort='name'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add python documentation. Document cases where an exception will be raised.


return total, graph_versions

def get_graph_version_by_id(request, version_id):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc

def get_graph_version_by_id(request, version_id):
return db.get_graph_version_by_id(request.db_session, version_id)

def add_graph_version(request, name=None, description=None, owner_email=None, graph_json=None, graph_id=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc

raise Exception("Required Parameter is missing!")
return db.add_graph_version(request.db_session, name=name, description=description, owner_email=owner_email, graph_json=graph_json, graph_id=graph_id)

def delete_graph_version_by_id(request, graph_version_id):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc

@@ -458,3 +458,42 @@ def find_edges(db_session, is_directed=None, names=None, edges=None, graph_id=No
query = query.limit(limit).offset(offset)

return total, query.all()

@with_session
def find_graph_versions(db_session, names=None, graph_id=None, limit=None, offset=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydoc for all dal functions

------

"""
#authorization.validate(request, permission='GRAPH_UPDATE', graph_id=graph_id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not validating auth for delete operation?

@adbharadwaj
Copy link
Collaborator

@jahandaniyal I added some more Pre-Merge TODOs

@adbharadwaj
Copy link
Collaborator

adbharadwaj commented Jun 24, 2018

Sanity checks

  • Check if Graphspace searches across versions

@@ -37,7 +37,7 @@ def test_crud_operation(self):

# Create
self.session.add(User(email='owner@example.com', password="password", is_admin=0))
self.session.add(Graph(name='graph1', owner_email='owner@example.com', json='{}', is_public=0))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 'json' parameter as we are no longer storing graph_json and style_json in Graph Table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants