-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fork functionality #385
base: develop
Are you sure you want to change the base?
Fork functionality #385
Conversation
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/).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a documentation of how the forked graphs API request and response will look like. Make changes here - https://github.com/Murali-group/GraphSpace/blob/master/api_specifications/api.raml
Use some RAML editor. In the past, we have used API Workbench
You are also missing User documentation. I will not be able to pull the request unless you submit the User documentation.
@@ -333,10 +333,11 @@ def delete_graph_to_group(request, group_id, graph_id): | |||
|
|||
|
|||
def search_graphs1(request, owner_email=None, names=None, nodes=None, edges=None, tags=None, member_email=None, | |||
is_public=None, query=None, limit=20, offset=0, order='desc', sort='name'): | |||
is_public=None, is_forked=None, query=None, limit=20, offset=0, order='desc', sort='name'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure you are using pycharm editor and running auto formatting before committing the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Followed PEP8 conventions for all python codes.
applications/graphs/controllers.py
Outdated
@@ -362,6 +363,7 @@ def search_graphs1(request, owner_email=None, names=None, nodes=None, edges=None | |||
owner_email=owner_email, | |||
graph_ids=graph_ids, | |||
is_public=is_public, | |||
is_forked=is_forked, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting doesnt look right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing it now.
applications/graphs/dal.py
Outdated
def add_fork(db_session, forked_graph_id, parent_graph_id, owner_email): | ||
fork = GraphFork( graph_id=forked_graph_id, parent_graph_id=parent_graph_id, owner_email=owner_email) | ||
db_session.add(fork) | ||
return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fork object. Refer to other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add python docs. Refer to other functions.
|
||
|
||
def upgrade(): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing it.
Forked GraphSpace Manual repo and installed API Workbench on Atom. |
Purpose
This patch fixes #336 - Allow users to fork/clone a graph.
Feature Details
parent-to-fork
graph relationship entry from the database.parent-to-fork
graph(s) relationship entries from the database. The Forked graphs will now behave just like Owned Graphs.Approach
Forking option is only available for public and shared graphs not owned by the current User.
I have created the Fork REST Api to handle Forking requests. User can send an
add fork
request using the Fork POST method. Graph details and JSON data is passed along with the request body. I am checking for user authentication and allowing only GET and POST requests from the user.For saving a fork I am using the following approach :
From the request body I extract and store the ID of the graph as
parent_graph_id
, then I create a new graph using the existingadd_graph
functionality. When a new graph has been created I will insert a record in the graph_fork table with thegraph_id
of the new graph just created and theparent_graph_id
.Populating Index Page tables :
Forked Graph index page is populated in a way similar to Public Graphs. Index pages of all graphs are populated using the Graph search feature, for example, in case of public graphs parameter
is_public
is passed to the search function. For forked graphs I am using the parameteris_forked
. I have used this approach because a forked graph can also be considered as an Owned Graph therefore it needs a way to be found using the Graph API's search endpoint.TEST CASES
Observation : Works without any issues.
Observation : Forked graph tab is not visible for anonymous users. It is visible only for signed-in users
Observation : Shows the forked graphs list correctly in the UI.
Observation : The graph is removed from the database and Owned/Forked Graph table.
parent_to_fork
entry is erased fromgraph_fork
table in the database.Observation : Parent Graph is removed from the database. All
parent_to_fork
entries are erased fromgraph_fork
table in the database. This operations does not remove the Forked Graphs from the database, it only erases theparent_to_fork
relationship information.Observation : Displays the number of times the Parent Graph has been forked (Pending). Hidden for all Owned/Private Graphs. Disabled after a successful Fork operation.
Open Questions and Pre-Merge TODOs
Learning
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem
Blog Posts