Warning
This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
galaxy.model.store package¶
- class galaxy.model.store.StoreAppProtocol(*args, **kwds)[source]¶
Bases:
Protocol
Define the parts of a Galaxy-like app consumed by model store.
- object_store: ObjectStore¶
- security: IdEncodingHelper¶
- tag_handler: GalaxyTagHandler¶
- model: GalaxyModelMapping¶
- file_sources: ConfiguredFileSources¶
- __init__(*args, **kwargs)¶
- class galaxy.model.store.ImportDiscardedDataType(value)[source]¶
Bases:
Enum
An enumeration.
- FORBID = 'forbid'¶
- ALLOW = 'allow'¶
- FORCE = 'force'¶
- class galaxy.model.store.ImportOptions(allow_edit=False, allow_library_creation=False, allow_dataset_object_edit=None, discarded_data=ImportDiscardedDataType.FORBID)[source]¶
Bases:
object
- __init__(allow_edit=False, allow_library_creation=False, allow_dataset_object_edit=None, discarded_data=ImportDiscardedDataType.FORBID)[source]¶
- discarded_data: ImportDiscardedDataType¶
- galaxy.model.store.replace_metadata_file(metadata: Dict[str, Any], dataset_instance: DatasetInstance, sa_session)[source]¶
- class galaxy.model.store.ModelImportStore(import_options=None, app: Optional[StoreAppProtocol] = None, user=None, object_store=None, tag_handler=None)[source]¶
Bases:
object
- __init__(import_options=None, app: Optional[StoreAppProtocol] = None, user=None, object_store=None, tag_handler=None)[source]¶
- app: Optional[StoreAppProtocol]¶
- abstract new_history_properties() Dict[str, Any] [source]¶
Dict of history properties if defines_new_history() is truthy.
- class galaxy.model.store.ObjectImportTracker[source]¶
Bases:
object
Keep track of new and existing imported objects.
Needed to re-establish connections and such in multiple passes.
- hdas_by_id: Dict[int, HistoryDatasetAssociation]¶
- hdcas_by_id: Dict[int, HistoryDatasetCollectionAssociation]¶
- dces_by_id: Dict[int, DatasetCollectionElement]¶
- requires_hid: List[Union[HistoryDatasetAssociation, HistoryDatasetCollectionAssociation]]¶
- exception galaxy.model.store.FileTracebackException(traceback, *args, **kwargs)[source]¶
Bases:
Exception
- class galaxy.model.store.DictImportModelStore(store_as_dict, **kwd)[source]¶
Bases:
ModelImportStore
- object_key = 'encoded_id'¶
- app: Optional[StoreAppProtocol]¶
- class galaxy.model.store.BaseDirectoryImportModelStore(import_options=None, app: Optional[StoreAppProtocol] = None, user=None, object_store=None, tag_handler=None)[source]¶
Bases:
ModelImportStore
- property file_source_root¶
Source of valid file data.
- app: Optional[StoreAppProtocol]¶
- class galaxy.model.store.DirectoryImportModelStore1901(archive_dir, **kwd)[source]¶
Bases:
BaseDirectoryImportModelStore
- object_key = 'hid'¶
- app: Optional[StoreAppProtocol]¶
- class galaxy.model.store.DirectoryImportModelStoreLatest(archive_dir, **kwd)[source]¶
Bases:
BaseDirectoryImportModelStore
- object_key = 'encoded_id'¶
- app: Optional[StoreAppProtocol]¶
- class galaxy.model.store.BagArchiveImportModelStore(bag_archive, **kwd)[source]¶
Bases:
DirectoryImportModelStoreLatest
- app: Optional[StoreAppProtocol]¶
- class galaxy.model.store.ModelExportStore[source]¶
Bases:
object
- abstract export_history(history: History, include_hidden: bool = False, include_deleted: bool = False)[source]¶
Export history to store.
- abstract export_library(history, include_hidden=False, include_deleted=False)[source]¶
Export library to store.
- abstract export_workflow_invocation(workflow_invocation, include_hidden=False, include_deleted=False)[source]¶
Export workflow invocation to store.
- abstract add_dataset_collection(collection: Union[DatasetCollection, HistoryDatasetCollectionAssociation])[source]¶
Add Dataset Collection or HDCA to export store.
- abstract add_dataset(dataset: DatasetInstance, include_files: bool = True)[source]¶
Add HDA to export store.
include_files
controls whether file contents are exported as well.
- class galaxy.model.store.DirectoryModelExportStore(export_directory: str, app: Optional[StoreAppProtocol] = None, file_sources: Optional[ConfiguredFileSources] = None, for_edit: bool = False, serialize_dataset_objects=None, export_files: Optional[str] = None, strip_metadata_files: bool = True, serialize_jobs: bool = True, user_context=None)[source]¶
Bases:
ModelExportStore
- __init__(export_directory: str, app: Optional[StoreAppProtocol] = None, file_sources: Optional[ConfiguredFileSources] = None, for_edit: bool = False, serialize_dataset_objects=None, export_files: Optional[str] = None, strip_metadata_files: bool = True, serialize_jobs: bool = True, user_context=None) None [source]¶
- Parameters
export_directory – path to export directory. Will be created if it does not exist.
app – Galaxy App or app-like object. Must be provided if for_edit and/or serialize_dataset_objects are True
for_edit – Allow modifying existing HDA and dataset metadata during import.
serialize_dataset_objects – If True will encode IDs using the host secret. Defaults for_edit.
export_files – How files should be exported, can be ‘symlink’, ‘copy’ or None, in which case files will not be serialized.
serialize_jobs – Include job data in model export. Not needed for set_metadata script.
- app: Optional[StoreAppProtocol]¶
- file_sources: Optional[ConfiguredFileSources]¶
- property workflows_directory¶
- export_jobs(jobs: List[Job], jobs_attrs=None, include_job_data=True)[source]¶
Export jobs.
include_job_data
determines whether datasets associated with jobs should be exported as well. This should generally beTrue
, except when re-exporting a job (to store the generated command line) when running the set_meta script.
- export_history(history: History, include_hidden: bool = False, include_deleted: bool = False) None [source]¶
Export history to store.
- export_library(library: Library, include_hidden=False, include_deleted=False)[source]¶
Export library to store.
- export_library_folder(library_folder: LibraryFolder, include_hidden=False, include_deleted=False)[source]¶
- export_library_folder_contents(library_folder: LibraryFolder, include_hidden=False, include_deleted=False)[source]¶
- export_workflow_invocation(workflow_invocation: WorkflowInvocation, include_hidden=False, include_deleted=False)[source]¶
Export workflow invocation to store.
- add_job_output_dataset_associations(job_id: int, name: str, dataset_instance: DatasetInstance) None [source]¶
- export_collection(collection: Union[DatasetCollection, HistoryDatasetCollectionAssociation], include_deleted: bool = False, include_hidden: bool = False) None [source]¶
- add_dataset_collection(collection: Union[DatasetCollection, HistoryDatasetCollectionAssociation]) None [source]¶
Add Dataset Collection or HDCA to export store.
- add_dataset(dataset: DatasetInstance, include_files: bool = True) None [source]¶
Add HDA to export store.
include_files
controls whether file contents are exported as well.
- class galaxy.model.store.TarModelExportStore(uri, gzip=True, **kwds)[source]¶
Bases:
DirectoryModelExportStore
- __init__(uri, gzip=True, **kwds)[source]¶
- Parameters
export_directory – path to export directory. Will be created if it does not exist.
app – Galaxy App or app-like object. Must be provided if for_edit and/or serialize_dataset_objects are True
for_edit – Allow modifying existing HDA and dataset metadata during import.
serialize_dataset_objects – If True will encode IDs using the host secret. Defaults for_edit.
export_files – How files should be exported, can be ‘symlink’, ‘copy’ or None, in which case files will not be serialized.
serialize_jobs – Include job data in model export. Not needed for set_metadata script.
- app: Optional[StoreAppProtocol]¶
- file_sources: Optional[ConfiguredFileSources]¶
- included_datasets: Dict[DatasetInstance, Tuple[DatasetInstance, bool]]¶
- included_collections: List[Union[DatasetCollection, HistoryDatasetCollectionAssociation]]¶
- included_library_folders: List[LibraryFolder]¶
- included_invocations: List[WorkflowInvocation]¶
- collections_attrs: List[Union[DatasetCollection, HistoryDatasetCollectionAssociation]]¶
- class galaxy.model.store.BagDirectoryModelExportStore(out_directory, **kwds)[source]¶
Bases:
DirectoryModelExportStore
- app: Optional[StoreAppProtocol]¶
- file_sources: Optional[ConfiguredFileSources]¶
- included_datasets: Dict[DatasetInstance, Tuple[DatasetInstance, bool]]¶
- included_collections: List[Union[DatasetCollection, HistoryDatasetCollectionAssociation]]¶
- included_library_folders: List[LibraryFolder]¶
- included_invocations: List[WorkflowInvocation]¶
- collections_attrs: List[Union[DatasetCollection, HistoryDatasetCollectionAssociation]]¶
- __init__(out_directory, **kwds)[source]¶
- Parameters
export_directory – path to export directory. Will be created if it does not exist.
app – Galaxy App or app-like object. Must be provided if for_edit and/or serialize_dataset_objects are True
for_edit – Allow modifying existing HDA and dataset metadata during import.
serialize_dataset_objects – If True will encode IDs using the host secret. Defaults for_edit.
export_files – How files should be exported, can be ‘symlink’, ‘copy’ or None, in which case files will not be serialized.
serialize_jobs – Include job data in model export. Not needed for set_metadata script.
- class galaxy.model.store.BagArchiveModelExportStore(uri, bag_archiver='tgz', **kwds)[source]¶
Bases:
BagDirectoryModelExportStore
- app: Optional[StoreAppProtocol]¶
- file_sources: Optional[ConfiguredFileSources]¶
- included_datasets: Dict[DatasetInstance, Tuple[DatasetInstance, bool]]¶
- included_collections: List[Union[DatasetCollection, HistoryDatasetCollectionAssociation]]¶
- included_library_folders: List[LibraryFolder]¶
- included_invocations: List[WorkflowInvocation]¶
- collections_attrs: List[Union[DatasetCollection, HistoryDatasetCollectionAssociation]]¶
- __init__(uri, bag_archiver='tgz', **kwds)[source]¶
- Parameters
export_directory – path to export directory. Will be created if it does not exist.
app – Galaxy App or app-like object. Must be provided if for_edit and/or serialize_dataset_objects are True
for_edit – Allow modifying existing HDA and dataset metadata during import.
serialize_dataset_objects – If True will encode IDs using the host secret. Defaults for_edit.
export_files – How files should be exported, can be ‘symlink’, ‘copy’ or None, in which case files will not be serialized.
serialize_jobs – Include job data in model export. Not needed for set_metadata script.
- galaxy.model.store.get_export_store_factory(app, download_format: str, export_files=None, user_context=None) Callable[[str], ModelExportStore] [source]¶
- galaxy.model.store.tar_export_directory(export_directory: str, out_file: str, gzip: bool) None [source]¶
- galaxy.model.store.get_export_dataset_filename(name, ext, hid)[source]¶
Builds a filename for a dataset using its name an extension.
- galaxy.model.store.source_to_import_store(source: Union[str, dict], app: StoreAppProtocol, import_options: Optional[ImportOptions], model_store_format: Optional[ModelStoreFormat] = None, user_context=None) ModelImportStore [source]¶
Submodules¶
galaxy.model.store.discover module¶
Utilities for discovering files to add to a model store.
Working with input “JSON” format used for Fetch API, galaxy.json imports, etc… High-level utilities in this file can be used during job output discovery or for persisting Galaxy model objects corresponding to files in other contexts.
- exception galaxy.model.store.discover.MaxDiscoveredFilesExceededError[source]¶
Bases:
ValueError
- class galaxy.model.store.discover.ModelPersistenceContext[source]¶
Bases:
object
Class for creating datasets while finding files.
This class implement the create_dataset method that takes care of populating metadata required for datasets and other potential model objects.
- max_discovered_files = inf¶
- create_dataset(ext, designation, visible, dbkey, name, filename=None, extra_files=None, metadata_source_name=None, info=None, library_folder=None, link_data=False, primary_data=None, init_from=None, dataset_attributes=None, tag_list=None, sources=None, hashes=None, created_from_basename=None, final_job_state='ok', creating_job_id=None, storage_callbacks=None)[source]¶
- populate_collection_elements(collection, root_collection_builder, discovered_files, name=None, metadata_source_name=None, final_job_state='ok')[source]¶
- abstract property tag_handler¶
Return a galaxy.model.tags.TagHandler-like object for persisting tags.
- abstract property user¶
If bound to a database, return the user the datasets should be created for.
Return None otherwise.
- abstract property sa_session: Optional[scoped_session]¶
If bound to a database, return the SQL Alchemy session.
Return None otherwise.
- abstract property permission_provider: PermissionProvider¶
If bound to a database, return the SQL Alchemy session.
Return None otherwise.
- abstract property job: Optional[Job]¶
Return associated job object if bound to a job finish context connected to a database.
- abstract property metadata_source_provider: MetadataSourceProvider¶
Return associated MetadataSourceProvider object.
- abstract property object_store: ObjectStore¶
Return object store to use for populating discovered dataset contents.
- abstract add_library_dataset_to_folder(library_folder, ld)[source]¶
Add library dataset to persisted library folder.
- abstract create_library_folder(parent_folder, name, description)[source]¶
Create a library folder ready from supplied attributes for supplied parent.
- abstract add_output_dataset_association(name, dataset)[source]¶
If discovering outputs for a job, persist output dataset association.
- add_datasets_to_history(datasets, for_output_dataset=None)[source]¶
Add datasets to the history this context points at.
- class galaxy.model.store.discover.PermissionProvider[source]¶
Bases:
object
Interface for working with permissions while importing datasets with ModelPersistenceContext.
- property permissions¶
- class galaxy.model.store.discover.UnusedPermissionProvider[source]¶
Bases:
PermissionProvider
- class galaxy.model.store.discover.MetadataSourceProvider[source]¶
Bases:
object
Interface for working with fetching input dataset metadata with ModelPersistenceContext.
- class galaxy.model.store.discover.UnusedMetadataSourceProvider[source]¶
Bases:
MetadataSourceProvider
- class galaxy.model.store.discover.SessionlessModelPersistenceContext(object_store, export_store, working_directory)[source]¶
Bases:
ModelPersistenceContext
A variant of ModelPersistenceContext that persists to an export store instead of database directly.
- property tag_handler¶
Return a galaxy.model.tags.TagHandler-like object for persisting tags.
- property sa_session¶
If bound to a database, return the SQL Alchemy session.
Return None otherwise.
- property user¶
If bound to a database, return the user the datasets should be created for.
Return None otherwise.
- property job¶
Return associated job object if bound to a job finish context connected to a database.
- property permission_provider: UnusedPermissionProvider¶
If bound to a database, return the SQL Alchemy session.
Return None otherwise.
- property metadata_source_provider: UnusedMetadataSourceProvider¶
Return associated MetadataSourceProvider object.
- property object_store: ObjectStore¶
Return object store to use for populating discovered dataset contents.
- add_library_dataset_to_folder(library_folder, ld)[source]¶
Add library dataset to persisted library folder.
- create_library_folder(parent_folder, name, description)[source]¶
Create a library folder ready from supplied attributes for supplied parent.
- persist_library_folder(library_folder)[source]¶
Add library folder to sessionless export. Noop for session export.
- add_datasets_to_history(datasets, for_output_dataset=None)[source]¶
Add datasets to the history this context points at.
- persist_object(obj)[source]¶
No-op right now for the sessionless variant of this.
This works currently because either things are added to a target history with add_datasets_to_history or the parent LibraryFolder was added to the export store in persist_target_to_export_store.
- galaxy.model.store.discover.persist_extra_files(object_store, src_extra_files_path, primary_data)[source]¶
- galaxy.model.store.discover.persist_target_to_export_store(target_dict, export_store, object_store, work_directory)[source]¶
- galaxy.model.store.discover.persist_elements_to_hdca(model_persistence_context: ModelPersistenceContext, elements, hdca, collector=None)[source]¶
- galaxy.model.store.discover.persist_elements_to_folder(model_persistence_context, elements, library_folder)[source]¶
- galaxy.model.store.discover.persist_hdas(elements, model_persistence_context, final_job_state='ok')[source]¶
- class galaxy.model.store.discover.DiscoveredFile(path, collector, match)[source]¶
Bases:
tuple
- property path¶
Alias for field number 0
- property collector¶
Alias for field number 1
- property match¶
Alias for field number 2
- class galaxy.model.store.discover.DiscoveredResultState(info, state)[source]¶
Bases:
tuple
- property info¶
Alias for field number 0
- property state¶
Alias for field number 1
- class galaxy.model.store.discover.DiscoveredDeferredFile(collector, match)[source]¶
Bases:
tuple
- property collector¶
Alias for field number 0
- property match¶
Alias for field number 1
- property path¶
- galaxy.model.store.discover.discovered_file_for_element(dataset, model_persistence_context: ModelPersistenceContext, parent_identifiers=None, collector=None) Union[DiscoveredFile, DiscoveredDeferredFile, DiscoveredFileError] [source]¶
- class galaxy.model.store.discover.JsonCollectedDatasetMatch(as_dict, collector: Optional[Any], filename, path=None, parent_identifiers=None)[source]¶
Bases:
object
- property designation¶
- property element_identifiers¶
- property raw_element_identifiers¶
- property name¶
Return name or None if not defined by the discovery pattern.
- property dbkey¶
- property ext¶
- property visible¶
- property link_data¶
- property tag_list¶
- property object_id¶
- property sources¶
- property hashes¶
- property created_from_basename¶
- property extra_files¶
- property effective_state¶
- class galaxy.model.store.discover.RegexCollectedDatasetMatch(re_match, collector: Optional[Any], filename, path=None)[source]¶
Bases:
JsonCollectedDatasetMatch