def jobzip(self, job, **jobargs): """ A hook provided by the :class:`Worker` for creating the :term:`job home` zip. :return: a :class:`disco.fileutils.DiscoZipFile`. """ from clx import __file__ as clxpath from disco import __file__ as discopath from disco.fileutils import DiscoZipFile jobzip = DiscoZipFile() jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', )) jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', )) jobzip.writesource(job) jobzip.writesource(self) return jobzip
def jobzip(self, job, **jobargs): """ A hook provided by the :class:`Worker` for creating the :term:`job home` zip. :return: a :class:`disco.fileutils.DiscoZipFile`. """ from clx import __file__ as clxpath from disco import __file__ as discopath from disco.fileutils import DiscoZipFile jobzip = DiscoZipFile() jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', '__pycache__')) jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', '__pycache__')) jobzip.writesource(job) jobzip.writesource(self) return jobzip
def jobzip(*paths): jobzip = DiscoZipFile() for path in paths: jobzip.writepath(path) jobzip.close() return jobzip
def jobzip(self, job, **jobargs): """ A hook provided by the :class:`Worker` for creating the :term:`job home` zip. The base implementation creates a minimal zip file containing the Disco standard library, and any user-specified required files and modules. :return: a :class:`disco.fileutils.DiscoZipFile`. """ # First, add the disco standard library. from clx import __file__ as clxpath from disco import __file__ as discopath from disco.fileutils import DiscoZipFile jobzip = DiscoZipFile() jobzip.writepath(os.path.dirname(clxpath), exclude=('.pyc', '__pycache__')) jobzip.writepath(os.path.dirname(discopath), exclude=('.pyc', '__pycache__')) jobzip.writesource(job) jobzip.writesource(self) # Then, add any user-specified required files. from disco.util import iskv def get(key): return self.getitem(key, job, jobargs) if isinstance(get('required_files'), dict): for path, bytes in get('required_files').items(): jobzip.writestr(path, bytes) else: for path in get('required_files'): jobzip.write(path, os.path.join('lib', os.path.basename(path))) if get('required_modules') is None: self['required_modules'] = self.get_modules(job, **jobargs) for mod in get('required_modules'): if iskv(mod): jobzip.writepath(mod[1]) # Done with basic minimal zip. return jobzip