[Notes] [Git][BuildGrid/buildgrid][arber/91-get-tree] start implementation of getTree method



Title: GitLab

Arber Xhindoli pushed to branch arber/91-get-tree at BuildGrid / buildgrid

Commits:

4 changed files:

Changes:

  • buildgrid/server/cas/instance.py
    ... ... @@ -54,6 +54,13 @@ class ContentAddressableStorageInstance:
    54 54
     
    
    55 55
             return response
    
    56 56
     
    
    57
    +    def get_tree(self, root_digest, page_size):
    
    58
    +        storage = self._storage
    
    59
    +        directories = []
    
    60
    +        directory = storage.fetch_directory(root_digest)
    
    61
    +        response = re_pb2.GetTreeResponse()
    
    62
    +        return response
    
    63
    +
    
    57 64
     
    
    58 65
     class ByteStreamInstance:
    
    59 66
     
    

  • buildgrid/server/cas/service.py
    ... ... @@ -83,6 +83,24 @@ class ContentAddressableStorageService(remote_execution_pb2_grpc.ContentAddressa
    83 83
         def GetTree(self, request, context):
    
    84 84
             context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    
    85 85
             context.set_details('Method not implemented!')
    
    86
    +        return iter([remote_execution_pb2.GetTreeResponse()])
    
    87
    +        try:
    
    88
    +            instance = self._get_instance(request.instance_name)
    
    89
    +            page_token = request.page_token
    
    90
    +            while True:
    
    91
    +                self.logger.debug("GetTree request: [{}]".format(request))
    
    92
    +                # returns GetTreeResponse
    
    93
    +                response = instance.get_tree(request.root_digest, request.page_size)
    
    94
    +                # set the page_token to the next one
    
    95
    +                page_token = response.next_page_token
    
    96
    +                yield response
    
    97
    +                if not page_token:
    
    98
    +                    return iter(())
    
    99
    +                # TODO: construct the next request
    
    100
    +        except InvalidArgumentError as e:
    
    101
    +            self.logger.error(e)
    
    102
    +            context.set_details(str(e))
    
    103
    +            context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
    
    86 104
     
    
    87 105
             return iter([remote_execution_pb2.GetTreeResponse()])
    
    88 106
     
    

  • buildgrid/server/cas/storage/storage_abc.py
    ... ... @@ -22,7 +22,7 @@ The abstract base class for storage providers.
    22 22
     
    
    23 23
     import abc
    
    24 24
     
    
    25
    -from buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2 import Digest
    
    25
    +from buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2 import Digest, Directory
    
    26 26
     from buildgrid._protos.google.rpc.status_pb2 import Status
    
    27 27
     from buildgrid._protos.google.rpc import code_pb2
    
    28 28
     
    
    ... ... @@ -97,6 +97,10 @@ class StorageABC(abc.ABC):
    97 97
                         result.append(Status(code=code_pb2.OK))
    
    98 98
             return result
    
    99 99
     
    
    100
    +    def fetch_directory(self, root_digest):
    
    101
    +        """Fetch a directory given the root_digest"""
    
    102
    +        return self.get_message(root_digest, Directory)
    
    103
    +
    
    100 104
         def put_message(self, message):
    
    101 105
             """Store the given Protobuf message in CAS, returning its digest."""
    
    102 106
             message_blob = message.SerializeToString()
    

  • setup.cfg
    ... ... @@ -2,7 +2,8 @@
    2 2
     test = pytest
    
    3 3
     
    
    4 4
     [tool:pytest]
    
    5
    -addopts = --verbose --pep8 --pylint --pylint-rcfile=.pylintrc --cov=buildgrid --cov-config=.coveragerc
    
    5
    +# FIXME before submit remove --no-pylint to --pylint
    
    6
    +addopts = --verbose --pep8 --no-pylint --pylint-rcfile=.pylintrc --cov=buildgrid --cov-config=.coveragerc --pdb
    
    6 7
     python_files = tests/*.py
    
    7 8
     pep8maxlinelength = 119
    
    8 9
     pep8ignore =
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]