arguments) else: cmd += " %s %s %s %s" % (executable.path, mpi_options, executable.options, arguments) print cmd return cmd generate_command.__doc__ = LaunchMode.generate_command.__doc__ def __getstate__(self): """Return a dict containing the values needed to recreate this instance.""" return { 'mpirun': self.mpirun, 'n': self.n, 'options': self.options, 'working_directory': self.working_directory } registry.add_component_type(LaunchMode) registry.register(SerialLaunchMode) registry.register(DistributedLaunchMode) registry.register(SlurmMPILaunchMode) def get_launch_mode(mode_name): """ Return a :class:`LaunchMode` object of the appropriate type. """ return registry.components[LaunchMode][mode_name]
tf = tarfile.open(label + ".tar.gz", "w:gz") logging.info("Archiving data to file %s" % tf.name) # Add data files archive_paths = [] for file_path in files: archive_path = os.path.join(label, file_path) tf.add(os.path.join(self.root, file_path), archive_path) archive_paths.append(archive_path) tf.close() # Move the archive to self.archive_store shutil.copy( tf.name, self.archive_store ) # shutil.move() doesn't work as expected if dataroot is a symbolic link os.remove(tf.name) # Delete original files. if delete_originals: for file_path in files: os.remove(os.path.join(self.root, file_path)) self._last_label = label # useful for testing return archive_paths def delete(self, *keys): """Delete the files corresponding to the given keys.""" raise NotImplementedError("Deletion of individual files not supported.") def contains_path(self, path): raise NotImplementedError registry.register(ArchivingFileSystemDataStore)
django_store2 = None class MockExecutable(Executable): name = "a.out" executable_names = ("/usr/local/bin/a.out", ) file_extensions = [] path = "/usr/local/bin/a.out" version = "999" options = "-v" def __init__(self, *args, **kwargs): pass registry.register(MockExecutable) class MockRepository(object): url = "http://svn.example.com/" upstream = None type = "MockRepository" def __init__(self, *args, **kwargs): pass class MockLaunchMode(object): type = "SerialLaunchMode" def __getstate__(self):
originals = [] django_store1 = None django_store2 = None class MockExecutable(Executable): name = "a.out" executable_names = ("/usr/local/bin/a.out",) file_extensions = [] path = "/usr/local/bin/a.out" version = "999" options = "-v" def __init__(self, *args, **kwargs): pass registry.register(MockExecutable) class MockRepository(object): url = "http://svn.example.com/" upstream = None type = "MockRepository" def __init__(self, *args, **kwargs): pass class MockLaunchMode(object): type = "SerialLaunchMode" def __getstate__(self): return {}
@property def exists(self): if urlparse(self.url).scheme == 'file' or have_internet_connection(): # check that there is a valid Subversion repository at the URL, # without doing a checkout. try: self._client.ls(self.url) except pysvn._pysvn.ClientError: return False return True def checkout(self, path='.'): try: self._client.checkout(self.url, path) except pysvn._pysvn.ClientError: # assume this is an 'object of the same name already exists' error repos_contents = self._client.ls(self.url) os.mkdir(".smt_backup") for entry in repos_contents: filename = entry["name"][len(self.url) + 1:] if os.path.exists(filename): os.rename(filename, os.path.join(".smt_backup", filename)) self._client.checkout(self.url, path) def get_working_copy(self, path=None): return SubversionWorkingCopy(path) registry.register(SubversionRepository) registry.register(SubversionWorkingCopy)
logging.info("Archiving data to file %s" % tf.name) # Add data files archive_paths = [] for file_path in files: archive_path = os.path.join(label, file_path) tf.add(os.path.join(self.root, file_path), archive_path) archive_paths.append(archive_path) tf.close() # Move the archive to self.archive_store shutil.copy( tf.name, self.archive_store ) # shutil.move() doesn't work as expected if dataroot is a symbolic link os.remove(tf.name) # Delete original files. if delete_originals: for file_path in files: os.remove(os.path.join(self.root, file_path)) self._last_label = label # useful for testing return archive_paths def delete(self, *keys): """Delete the files corresponding to the given keys.""" raise NotImplementedError( "Deletion of individual files not supported.") def contains_path(self, path): raise NotImplementedError registry.register(ArchivingFileSystemDataStore)
self.mpirun, self.working_directory ) if main_file is not None: cmd += " %s %s %s %s %s" % (executable.path, mpi_options, executable.options, main_file, arguments) else: cmd += " %s %s %s %s" % (executable.path, mpi_options, executable.options, arguments) print cmd return cmd generate_command.__doc__ = LaunchMode.generate_command.__doc__ def __getstate__(self): """Return a dict containing the values needed to recreate this instance.""" return {'mpirun': self.mpirun, 'n': self.n, 'options': self.options, 'working_directory': self.working_directory} registry.add_component_type(LaunchMode) registry.register(SerialLaunchMode) registry.register(DistributedLaunchMode) registry.register(SlurmMPILaunchMode) def get_launch_mode(mode_name): """ Return a :class:`LaunchMode` object of the appropriate type. """ return registry.components[LaunchMode][mode_name]