Skip to content

Commit

Permalink
Merge pull request #10 from datmo/datmo-with-git
Browse files Browse the repository at this point in the history
Add further compatibility of datmo with git flows
  • Loading branch information
asampat3090 committed Apr 18, 2018
2 parents df4d197 + 3e3253a commit 0ea8024
Show file tree
Hide file tree
Showing 13 changed files with 444 additions and 333 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include datmo/controller/code/driver/templates/gitignore
include datmo/controller/environment/driver/templates/baseDockerfile
recursive-include templates *
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,22 @@ as you start new projects.
In the `/examples` folder we have a few projects that have already been created and converted to datmo. You can
navigate to them and try datmo commands for yourself in order to get a feel for the tool.

## Sharing (Beta)
Although datmo is made to track your changes locally, you can share a project with your
friends by doing the following (this is shown only for git, if you are using another git
tracking tool, you can likely do something similar). NOTE: If your files are too big or
cannot be added to SCM then this may not work for you.
```
$ git add -f .datmo/*
$ git commit -m "my_message"
$ git push
$ git push origin +refs/datmo/*:refs/datmo/*
```
The above will allow you to share datmo results and entities with yourself or others on
other machines. NOTE: you will have to remove .datmo/ from tracking to start using datmo
on the other machine. To do that you can use the commands below
```
$ git rm -r --cached
$ git add .
$ git commit -m "removed .datmo from tracking"
```
7 changes: 3 additions & 4 deletions datmo/controller/code/code.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datmo.util.i18n import get as _
from datmo.controller.base import BaseController
from datmo.util.exceptions import RequiredArgumentMissing, \
DoesNotExistException
from datmo.util.exceptions import DoesNotExistException


class CodeController(BaseController):
Expand Down Expand Up @@ -55,7 +54,7 @@ def create(self, commit_id=None):
create_dict[required_arg] = commit_id
else:
create_dict[required_arg] = \
self.code_driver.create_code()
self.code_driver.create_ref()
# If code object with commit id exists, return it
results = self.dal.code.query({
"commit_id": create_dict[required_arg]
Expand Down Expand Up @@ -95,7 +94,7 @@ def delete(self, id):
"controller.code.delete",
id))
# Remove code reference
delete_code_success = self.code_driver.delete_code(code_obj.commit_id)
delete_code_success = self.code_driver.delete_ref(code_obj.commit_id)
# Delete code object
delete_code_obj_success = self.dal.code.delete(code_obj.id)

Expand Down
129 changes: 108 additions & 21 deletions datmo/controller/code/driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,136 @@ class CodeDriver(with_metaclass(ABCMeta, object)):
Methods
-------
create_code()
create code reference
exists_code()
check if code reference exists
delete_code()
delete code reference if exists
list_code()
list all code references
push_code()
push code reference given
fetch_code()
fetch code reference given
checkout_code()
checkout to code reference given
create_ref()
add remaining files, make a commit and add to datmo ref
exists_ref()
check if commit reference exists
delete_ref()
delete commit reference if exists
list_refs()
list all commit references
push_ref()
push commit reference given
fetch_ref()
fetch commit reference given
checkout_ref()
checkout to commit reference given
"""
@abstractmethod
def __init__(self):
pass

@abstractmethod
def create_code(self, code_id=None):
def create_ref(self, commit_id=None):
"""Add remaining files, make a commit and add to datmo ref
Parameters
----------
commit_id : str, optional
if commit_id is given, it will not add files and not create a commit
Returns
-------
commit_id : str
commit_id for the ref created
Raises
------
GitCommitDoesNotExist
commit id specified does not match a valid commit within the tree
"""
pass

@abstractmethod
def exists_code(self, code_id):
def exists_ref(self, commit_id):
"""Check if commit reference exists
Parameters
----------
commit_id : str
commit id specified to check if commit ref exists
Returns
-------
bool
True if exists else False
"""
pass

@abstractmethod
def delete_code(self, code_id):
def delete_ref(self, commit_id):
"""Delete commit ref if exists
Parameters
----------
commit_id : str
commit id for commit ref
Returns
-------
bool
True if success
"""
pass

@abstractmethod
def list_code(self):
def list_refs(self):
"""List all commit references
Returns
-------
list
includes all commit ref ids present
"""
pass

@abstractmethod
def push_code(self, code_id="*"):
def push_ref(self, commit_id="*"):
"""Push commit reference given
Parameters
----------
commit_id : str, optional
commit id for commit ref (default is * to signify
all refs)
Returns
-------
bool
True if success
"""
pass

@abstractmethod
def fetch_code(self, code_id):
def fetch_ref(self, commit_id):
"""Fetch commit reference given
Parameters
----------
commit_id : str
commit id for commit ref
Returns
-------
bool
True if success
"""
pass

@abstractmethod
def checkout_code(self, code_id, remote=False):
def checkout_ref(self, commit_id, remote=False):
"""Checkout commit reference given without affecting the .datmo directory
Parameters
----------
commit_id : str
commit id for commit ref
remote : bool
signifies if commit id should be fetched before checkout
Returns
-------
bool
True if success
"""
pass

0 comments on commit 0ea8024

Please sign in to comment.