Пример #1
0
    def save(self, path):
        """Save a file in the storage.

        Note:
            The file is moved to the storage, not copied.

        Args:
            path (str): A path where the file is located.

        Returns:
            str: The digest of the file.
        """
        if not os.path.exists(self.path):
            os.makedirs(self.path)
        digest = digest_file(path)
        dst_path = os.path.join(self.path, digest)
        shutil.move(path, dst_path)

        return digest
Пример #2
0
def make(target):
    '''
    Make target files.

    Run necessary calculations to generate the target
    files. If the target files already exist in cache, simply copy them into
    working directory.
    '''
    user = dict(name=settings['user.name'], id=settings['user.id'])
    log = gpc.Log(DEFAULT_LOG_PATH, user)
    storage = gpc.Storage(DEFAULT_STORAGE_PATH)
    graph = gpc.graph_from_spec('gpc.yaml')

    runner = gpc.Runner(log, storage, graph)
    for t in list(target):
        runner.make(t)

        responsible_runs = log.get_provenance(gpc.digest_file(t))
        print('The file was produced by %i run(s):' % len(responsible_runs))
        for r in responsible_runs:
            print(r)

    log.write()