def commit_from(src, allow_just_repo=False): if isinstance(src, pfs_proto.Commit): return src elif isinstance(src, (tuple, list)) and len(src) == 2: return pfs_proto.Commit(repo=pfs_proto.Repo(name=src[0]), id=src[1]) elif isinstance(src, six.string_types): repo_name, commit_id = src.split('/', 1) return pfs_proto.Commit(repo=pfs_proto.Repo(name=repo_name), id=commit_id) if not allow_just_repo: raise ValueError("Invalid commit type") return pfs_proto.Commit(repo=pfs_proto.Repo(name=src))
def start_commit(self, repo_name, branch=None, parent=None, description=None): """ Begins the process of committing data to a Repo. Once started you can write to the Commit with PutFile and when all the data has been written you must finish the Commit with FinishCommit. NOTE, data is not persisted until FinishCommit is called. A Commit object is returned. Params: * repo_name: The name of the repo. * branch: A more convenient way to build linear chains of commits. When a commit is started with a non-empty branch the value of branch becomes an alias for the created Commit. This enables a more intuitive access pattern. When the commit is started on a branch the previous head of the branch is used as the parent of the commit. * parent: Specifies the parent Commit, upon creation the new Commit will appear identical to the parent Commit, data can safely be added to the new commit without affecting the contents of the parent Commit. You may pass "" as parentCommit in which case the new Commit will have no parent and will initially appear empty. * description: (optional) explanation of the commit for clarity. """ req = proto.StartCommitRequest(parent=proto.Commit( repo=proto.Repo(name=repo_name), id=parent), branch=branch, description=description) res = self.stub.StartCommit(req, metadata=self.metadata) return res
def start_commit(self, repo_name, branch=None, parent=None, description=None, provenance=None): """ Begins the process of committing data to a Repo. Once started you can write to the Commit with PutFile and when all the data has been written you must finish the Commit with FinishCommit. NOTE, data is not persisted until FinishCommit is called. A Commit object is returned. Params: * repo_name: A string specifying the name of the repo. * branch: A string specifying the branch name. This is a more convenient way to build linear chains of commits. When a commit is started with a non-empty branch the value of branch becomes an alias for the created Commit. This enables a more intuitive access pattern. When the commit is started on a branch the previous head of the branch is used as the parent of the commit. * parent: An optional `Commit` object specifying the parent commit. Upon creation the new commit will appear identical to the parent commit, data can safely be added to the new commit without affecting the contents of the parent commit. * description: An optional string describing the commit. * provenance: An optional iterable of `CommitProvenance` objects specifying the commit provenance. """ req = proto.StartCommitRequest( parent=proto.Commit(repo=proto.Repo(name=repo_name), id=parent), branch=branch, description=description, provenance=provenance, ) return self.stub.StartCommit(req, metadata=self.metadata)
def subscribe_commit(self, repo_name, branch, from_commit_id=None, state=None): """ Yields `CommitInfo` objects as commits occur. Params: * repo_name: A string specifying the name of the repo. * branch: A string specifying branch to subscribe to. * from_commit_id: An optional string specifying the commit ID. Only commits created since this commit are returned. * state: The commit state to filter on. """ repo = proto.Repo(name=repo_name) req = proto.SubscribeCommitRequest(repo=repo, branch=branch, state=state) if from_commit_id is not None: getattr(req, 'from').CopyFrom(proto.Commit(repo=repo, id=from_commit_id)) return self.stub.SubscribeCommit(req, metadata=self.metadata)
def subscribe_commit(self, repo_name, branch, from_commit_id=None): """ SubscribeCommit is like ListCommit but it keeps listening for commits as they come in. This returns an iterator Commit objects. Params: * repo_name: Name of the repo. * branch: Branch to subscribe to. * from_commit_id: Optional. Only commits created since this commit are returned. """ repo = proto.Repo(name=repo_name) req = proto.SubscribeCommitRequest(repo=repo, branch=branch) if from_commit_id is not None: getattr(req, 'from').CopyFrom(proto.Commit(repo=repo, id=from_commit_id)) res = self.stub.SubscribeCommit(req, metadata=self.metadata) return res