Bamboost
bamboost/core/remote

bamboost.core.remote

Remote Access Module for Bamboost

This module provides the Remote class and related classes to facilitate access to remote collections and simulations in the Bamboost framework.

Typical usage involves creating a Remote instance pointing to a remote server, listing available collections, and synchronizing data as needed.

Attributes

  • log=BAMBOOST_LOGGER.getChild(__name__)

Functions

stream_popen_output(func) -> Callable[_P, None]

Decorator to await, capture and print the output of a subprocess.Popen object.

Arguments:
  • func:typing.Callable[_P, subprocess.subprocess.Popen]

Classes

Remote

Remote(self, remote_url, comm=None, *, workspace_path=None, workspace_name=None, skip_fetch=False)

Represents a remote index/database for accessing and synchronizing collections and simulations.

The Remote class manages connections to a remote server, handles local caching of remote data, and provides methods for synchronizing databases and collections using rsync. It supports workspace management and can list available remote databases in the local cache.

Arguments:
  • remote_url:str
  • comm:typing.Optional[Comm]=None
  • workspace_path:typing.Optional[str]=None
  • workspace_name:typing.Optional[str]=None
  • skip_fetch:bool=False
Attributes:
  • DATABASE_BASE_NAME:str='bamboost.sqlite'

    The base name of the database file.

  • DATABASE_REMOTE_PATH:pathlib.Path=_config.LOCAL_DIR.joinpath(_config.DATABASE_FILE_NAME)

    Default path to the remote database.

  • WORKSPACE_SPLITTER:str='_WS_'

    String used to split remote URL and workspace name.

  • _remote_url:str=bamboost.core.remote.Remote(remote_url)

    The SSH URL of the remote server.

  • id:str=f'{bamboost.core.remote.Remote(remote_url)}{bamboost.core.remote.Remote(self).bamboost.core.remote.Remote(self).WORKSPACE_SPLITTER}{bamboost.core.remote.Remote(workspace_name)}' if bamboost.core.remote.Remote(workspace_name) else bamboost.core.remote.Remote(remote_url)

    Unique identifier for the remote instance.

  • _local_path:pathlib.Path=Path(cache_dir).joinpath(self.id)

    Local cache path for the remote data.

  • _workspace_path:typing.Optional[str]=bamboost.core.remote.Remote(workspace_path)

    Path to the workspace on the remote server.

  • _workspace_name:typing.Optional[str]=bamboost.core.remote.Remote(workspace_name)

    Name of the workspace.

  • _remote_database_path:pathlib.Path=bamboost.core.remote.Remote(self).bamboost.core.remote.Remote(self).DATABASE_REMOTE_PATH

    Path to the remote database file.

  • _local_database_path:pathlib.Path=cache_dir.joinpath(f'{self.id}.sqlite')

    Path to the local cached database file.

  • search_paths:PathSet=PathSet([self._local_path])

    Set of search paths for collections.

  • _url:str=f'sqlite:///{bamboost.core.remote.Remote(self).bamboost.core.remote.Remote(self)._local_database_path}'

    SQLAlchemy database URL for the local cache.

  • _engine=create_engine(self._url, json_serializer=json_serializer, json_deserializer=json_deserializer)

    SQLAlchemy engine instance.

  • _sm=sessionmaker(bind=self._engine, autobegin=False, expire_on_commit=False)

    SQLAlchemy sessionmaker.

  • _s=self._sm()

    SQLAlchemy session.

Remote.__getitem__(self, key) -> RemoteCollection
Arguments:
  • key:str
Remote.__repr__(self) -> str
Remote.fetch_remote_database(self) -> subprocess.Popen

Fetch the remote SQL database.

Remote.rsync(self, source, dest) -> subprocess.Popen

Synchronize data from the remote server to the local cache using rsync.

Arguments:
  • source:StrPath

    The absolute source path on the remote server.

  • dest:StrPath

    The destination path on the local machine, relative to the local cache directory for this remote.

Returns
subprocess.subprocess.Popensubprocess.Popen: The Popen object for the rsync process.
Remote.list(cls) -> list[Remote]

List all remote databases in the cache.

Arguments:
  • cls
Remote.get_local_path(self, collection_uid) -> Path
Arguments:
  • collection_uid:str
Remote._from_id(cls, id) -> Remote
Arguments:
  • cls
  • id:str

RemoteCollection

RemoteCollection(self, uid, remote)
Arguments:
Attributes:
  • uid=CollectionUID(uid)
  • _index=bamboost.core.remote.RemoteCollection(remote)
  • path=remote._local_path.joinpath(uid)
  • remote_path=cast(Path, remote._get_collection_path(self.uid))
  • df:pandas.DataFrame
RemoteCollection.__getitem__(self, name) -> RemoteSimulation
Arguments:
  • name:str
RemoteCollection.rsync(self, name=None) -> Self

Transfer data using rsync. Wait for the process to finish and return self.

Arguments:
  • name:typing.Optional[str]=None

    The simulation name of the simulation to be transferred. If None, all simulations are synced.

RemoteSimulation

RemoteSimulation(self, name, collection_uid, index, comm=None, **kwargs)
Arguments:
Attributes:
  • name:str=bamboost.core.remote.RemoteSimulation(name)
  • path:pathlib.Path=index.get_local_path(collection_uid).joinpath(name)
  • remote_path:pathlib.Path=index._get_collection_path(collection_uid).joinpath(name)
  • collection_uid=bamboost.core.remote.RemoteSimulation(collection_uid)
  • _index:Remote=bamboost.core.remote.RemoteSimulation(index)
  • _data_file:pathlib.Path=self.path.joinpath(constants.HDF_DATA_FILE_NAME)
  • _xdmf_file:pathlib.Path=self.path.joinpath(constants.XDMF_FILE_NAME)
  • _bash_file:pathlib.Path=self.path.joinpath(constants.RUN_FILE_NAME)
  • uid:str
  • parameters:dict
  • metadata:dict

Sync the simulation data with the remote server.