cmem_client.repositories.marketplace_packages¤
Repository for the marketplace packages installed in Corporate Memory.
Provides MarketplacePackagesRepository for installing packages from an archive or
directory, exporting an installed package again and removing one. The packages
available on a marketplace server are offered by the Marketplace component
(client.marketplace) instead.
Examples:
List the installed packages:
>>> from cmem_client.client import Client
>>> client = Client.from_env()
>>> list(client.marketplace_packages)
Install a package archive and export an installed package:
>>> from pathlib import Path
>>> from cmem_client.repositories.marketplace_packages import (
... MarketplacePackagesExportConfig,
... MarketplacePackagesImportConfig,
... )
>>> from cmem_client.repositories.protocols.import_item import ImportConflictPolicy
>>> client.marketplace_packages.import_item(
... key="w3c-geo-vocab",
... configuration=MarketplacePackagesImportConfig(install_from_marketplace=True),
... on_conflict=ImportConflictPolicy.REPLACE
... )
>>> client.marketplace_packages.export_item(
... key="w3c-geo-vocab",
... path=Path("w3c-geo-vocab"),
... configuration=MarketplacePackagesExportConfig(export_as_zip=False),
... )
>>> client.marketplace_packages.delete_item(key="w3c-geo-vocab", skip_if_missing=True)
Classes:
- MarketplacePackagesDeleteConfig – Package deletion configuration
- MarketplacePackagesExportConfig – Package export configuration
- MarketplacePackagesImportConfig – Configuration for marketplace package import operations.
- MarketplacePackagesRepository – Repository for marketplace package operations.
Functions:
- get_installation_metadata_query – Get the query for the installation metadata of the package.
Attributes:
LOCK_FILE_RESOURCE¤
MAX_DEPENDENCY_DEPTH¤
MarketplacePackagesDeleteConfig¤
Bases: DeleteConfig
Package deletion configuration
Attributes:
- skip_missing_dependencies (
bool) – If True, dependencies which are not installed are skipped instead of raising an error. - skip_missing_graphs (
bool) – If True, graphs of the package which do not exist are skipped instead of raising an error. - skip_missing_projects (
bool) – If True, projects of the package which do not exist are skipped instead of raising an error. - ignore_lock (
bool) – If set to True, ignore the lock mechanism. - ignore_dependencies (
bool) – If True, dependencies of the package are not deleted. - dependency_level (
int) – Current recursion depth for dependency resolution. Used internally to identify the top-level call. Should not be set manually.
dependency_level¤
ignore_dependencies¤
ignore_lock¤
model_config¤
skip_missing_dependencies¤
skip_missing_graphs¤
skip_missing_projects¤
MarketplacePackagesExportConfig¤
Bases: ExportConfig
Package export configuration
Attributes:
- export_graph_serialization (
Literal[‘turtle’, ‘pretty-turtle’]) – Graph export serialization format. - export_as_zip (
bool) – If true, export the package as a zip file, otherwise as a directory.
export_as_zip¤
export_graph_serialization¤
model_config¤
MarketplacePackagesImportConfig¤
Bases: ImportConfig
Configuration for marketplace package import operations.
Attributes:
- ignore_dependencies (
bool) – If True, skips installation of package dependencies. - install_from_marketplace (
bool) – If True, downloads packages from the marketplace server. If False, loads packages from local filesystem. - package_version (
PackageVersionIdentifier | None) – Specific version to install. If None, installs the latest version. - dependency_level (
int) – Current recursion depth for dependency resolution. Used internally to prevent infinite recursion. Should not be set manually. - use_cache (
bool) – Weather to use the cache directory to look packages up which have already been downloaded. To prevent the cache entirely, set this up in the marketplace component. - ignore_lock (
bool) – If set to True, ignore the lock mechanism.
dependency_level¤
ignore_dependencies¤
ignore_lock¤
install_from_marketplace¤
model_config¤
package_version¤
use_archive_handler¤
use_cache¤
MarketplacePackagesRepository¤
Bases: Repository, ImportItemProtocol, ExportItemProtocol, DeleteItemProtocol
Repository for marketplace package operations.
Functions:
- delete_all – Delete all items from the repository
- delete_item – Delete an item from the repository
- export_item – Export an item from the repository to a file path.
- fetch_data – Fetch installed packages from the package data graph via SPARQL query.
- import_item – Import an exported file to the repository
- items – Get the items of the repository
- keys – Get the keys of the repository
- values – Get the values of the repository
Attributes:
- logger (
Logger) – Gets the client logger
delete_all¤
Delete all items from the repository
delete_item¤
Delete an item from the repository
Parameters:
- key (
str) – The key of the item to delete - skip_if_missing (
bool) – If True, it is ignored if the deleted item even exists - configuration (
DeleteItemConfig) – Optional configuration for deletion
Raises:
RepositoryModificationError– if an error occurs while creating the itemHTTPError– for any other http error
export_item¤
Export an item from the repository to a file path.
Parameters:
- key (
str) – The key identifying the item to export. - path (
Path | None) – The target file path for export. If None, a path will be generated. - replace (
bool) – Whether to replace existing files at the target path. - configuration (
ExportItemConfig_contra | None) – Optional configuration for export behavior.
Returns:
Path– The actual path where the item was exported.
Raises:
RepositoryItemNotFoundError– If the specified item key is not found.RepositoryReadError– If there’s an error during export or path mismatch.
fetch_data¤
Fetch installed packages from the package data graph via SPARQL query.
Queries the package data graph for all installed packages and their metadata.
import_item¤
Import an exported file to the repository
By default, automatically handles zip files, directories, and single files using ImportItem model. Can be disabled by setting use_archive_handler=False in the configuration.
Returns:
str– The key of the imported item.
Raises:
RepositoryModificationError– If the item already exists and the conflict policy is FAIL, if the import type is not allowed for this repository, if the import request failed, or if the item is not present afterwards.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
values¤
Get the values of the repository
get_installation_metadata_query¤
Get the query for the installation metadata of the package.