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
(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
(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
- 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.
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.
Bases
Index._comm
Index.default
Index._file
Index._isolated
Index._initialize_root_process()
Index.sql_transaction()
Index.scan_for_collections()
Index.check_integrity()
Index.resolve_path()
Index.resolve_uid()
Index.sync_collection()
Index.all_collections
Index.collection()
Index.all_simulations
Index.simulation()
Index.all_parameters
Index._drop_collection()
Index._drop_simulation()
Index.upsert_collection()
Index.upsert_simulation()
Index.update_simulation_metadata()
Index.update_simulation_parameters()
Index._get_collection_path()
Index._get_collections()
Index._get_simulation()
(self, key) -> RemoteCollection
Arguments:
- key:
str
(self) -> str
(self) -> subprocess.Popen
Fetch the remote SQL database.
(self, source, dest) -> subprocess.Popen
Synchronize data from the remote server to the local cache using rsync.
Arguments:
Returns
subprocess.subprocess.Popen
subprocess.Popen: The Popen object for the rsync process.(cls) -> list[Remote]
List all remote databases in the cache.
Arguments:
- cls
(self, collection_uid) -> Path
Arguments:
- collection_uid:
str
(cls, id) -> Remote
Arguments:
- cls
- id:
str
(self) -> list[str]
RemoteCollection
(self, uid, remote)
Arguments:
- uid:
str
- remote:
Remote
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
Bases
Collection.FROZEN
Collection.fromUID
Collection._comm
Collection._filter
Collection.k
Collection._orm
Collection.__len__()
Collection._ipython_key_completions_()
Collection.filter()
Collection.all_simulation_names()
Collection.sync_cache()
Collection.create_simulation()
Collection._delete_simulation()
Collection.find()
Collection._list_duplicates()
Collection._check_duplicate()
(self, name) -> RemoteSimulation
Arguments:
- name:
str
(self) -> list[str]
(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.
(self) -> str
RemoteSimulation
(self, name, collection_uid, index, comm=None, **kwargs)
Arguments:
- name:
str
- collection_uid:
CollectionUID
- index:
Remote
- kwargs=
{}
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)
- _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
Bases
_Simulation.mutable
_Simulation._psize
_Simulation._prank
_Simulation._ranks
_Simulation.__eq__()
_Simulation._repr_html_()
_Simulation.root
_Simulation._orm
_Simulation.from_uid()
_Simulation.edit()
_Simulation.update_database()
_Simulation.status
_Simulation.created_at
_Simulation.description
_Simulation.links
_Simulation.files
_Simulation.git
_Simulation.data
_Simulation.meshes
_Simulation.mesh
_Simulation.open_in_paraview()
_Simulation.enter_path()
_Simulation.require_series()
_Simulation.create_xdmf()
(self) -> Self
Sync the simulation data with the remote server.