Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ weight: 131
superheading: "catalog_workspace_content."
---

``store_analytics_model_to_disk(workspace_id: str, path: Path = Path.cwd())``
``store_analytics_model_to_disk(workspace_id: str, path: Path = Path.cwd(), exclude: Optional[list[str]] = None, sort: bool = False)``

Stores analytics model for a given workspace in directory hierarchy.This method does not tie the declarative analytics model to the workspace and organization, thus it is recommended for migration between workspaces. If you want to backup analytics model between workspaces or organizations, use [store_analytics_model_to_disk](../store_analytics_model_to_disk/).

Expand All @@ -31,6 +31,12 @@ Workspace identification string e.g. "demo"
{{< parameter p_name="path" p_type="Optional[Path]" >}}
Path to the root of the layout directory. Defaults to Path.cwd().
{{< /parameter >}}
{{< parameter p_name="exclude" p_type=" Optional[list[str]]" >}}
Defines properties which should not be included in the result. E.g.: ["ACTIVITY_INFO"] – refers to createdBy, etc. Default is None.
{{< /parameter >}}
{{< parameter p_name="sort" p_type="bool" >}}
Flag if the output should be sorted before storing to disk. Default is False.
{{< /parameter >}}
{{% /parameters-block %}}

{{% parameters-block title="Returns" None="yes" %}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ superheading: "catalog_workspace_content."
---


``store_ldm_to_disk(workspace_id: str, path: Path = Path.cwd())``
``store_ldm_to_disk(workspace_id: str, path: Path = Path.cwd(), sort: bool = False)``

Stores the declarative logical data model for a given workspace in directory hierarchy. This method does not tie the LDM to the workspace and organization, thus it is recommended for migration between organizations. If you want to backup LDM use [store_declarative_ldm](../store_declarative_ldm/).

Expand All @@ -26,6 +26,9 @@ Workspace identification string e.g. "demo"
{{< parameter p_name="path" p_type="Optional[Path]" >}}
Path to the root of the layout directory. Defaults to Path.cwd().
{{< /parameter >}}
{{< parameter p_name="sort" p_type="bool" >}}
Flag if the output should be sorted before storing to disk. Default is False.
{{< /parameter >}}
{{% /parameters-block %}}

{{% parameters-block title="Returns" None="yes" %}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ def client_class() -> type[DeclarativeDataSources]:
def data_sources_folder(layout_organization_folder: Path) -> Path:
return layout_organization_folder / LAYOUT_DATA_SOURCES_DIR

def store_to_disk(self, layout_organization_folder: Path) -> None:
def store_to_disk(self, layout_organization_folder: Path, sort: bool = False) -> None:
data_sources_folder = self.data_sources_folder(layout_organization_folder)
create_directory(data_sources_folder)
for data_source in self.data_sources:
data_source.store_to_disk(data_sources_folder)
data_source.store_to_disk(data_sources_folder, sort=sort)

@classmethod
def load_from_disk(cls, layout_organization_folder: Path) -> CatalogDeclarativeDataSources:
Expand Down Expand Up @@ -201,12 +201,12 @@ def to_api(
dictionary["client_secret"] = client_secret
return self.client_class().from_dict(dictionary)

def store_to_disk(self, data_sources_folder: Path) -> None:
def store_to_disk(self, data_sources_folder: Path, sort: bool = False) -> None:
data_source_folder = self.data_source_folder(data_sources_folder, self.id)
file_path = data_source_folder / f"{self.id}.yaml"
data_source_dict = self.to_api().to_dict(camel_case=True)

write_layout_to_file(file_path, data_source_dict)
write_layout_to_file(file_path, data_source_dict, sort=sort)

@classmethod
def load_from_disk(cls, data_sources_folder: Path, data_source_id: str) -> CatalogDeclarativeDataSource:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class CatalogDeclarativeTable(Base):
def client_class() -> builtins.type[DeclarativeTable]:
return DeclarativeTable

def store_to_disk(self, pdm_folder: Path) -> None:
def store_to_disk(self, pdm_folder: Path, sort: bool = False) -> None:
table_dict = self.to_api().to_dict(camel_case=True)
table_file_path = pdm_folder / f"{self.id}.yaml"
write_layout_to_file(table_file_path, table_dict)
write_layout_to_file(table_file_path, table_dict, sort=sort)

@classmethod
def load_from_disk(cls, table_file_path: Path) -> CatalogDeclarativeTable:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def load_from_disk(cls, layout_organization_folder: Path) -> CatalogDeclarativeU
users = [CatalogDeclarativeUser.from_dict(record, camel_case=True) for record in data]
return cls(users=users)

def store_to_disk(self, layout_organization_folder: Path) -> None:
def store_to_disk(self, layout_organization_folder: Path, sort: bool = False) -> None:
users_directory = layout_organization_folder / LAYOUT_USERS_DIR
users_file = users_directory / LAYOUT_USERS_FILE
create_directory(users_directory)
users = [user.to_dict(camel_case=True) for user in self.users]
write_layout_to_file(users_file, users)
write_layout_to_file(users_file, users, sort=sort)


@attr.s(auto_attribs=True, kw_only=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def load_from_disk(cls, layout_organization_folder: Path) -> CatalogDeclarativeU
user_groups = [CatalogDeclarativeUserGroup.from_dict(record, camel_case=True) for record in data]
return cls(user_groups=user_groups)

def store_to_disk(self, layout_organization_folder: Path) -> None:
def store_to_disk(self, layout_organization_folder: Path, sort: bool = False) -> None:
user_groups_directory = layout_organization_folder / LAYOUT_USER_GROUPS_DIR
user_groups_file = user_groups_directory / LAYOUT_USER_GROUPS_FILE
create_directory(user_groups_directory)
user_groups = [user_group.to_dict(camel_case=True) for user_group in self.user_groups]
write_layout_to_file(user_groups_file, user_groups)
write_layout_to_file(user_groups_file, user_groups, sort=sort)


@attr.s(auto_attribs=True, kw_only=True)
Expand Down
14 changes: 9 additions & 5 deletions gooddata-sdk/gooddata_sdk/catalog/workspace/content_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def load_and_put_declarative_ldm(
declarative_ldm = self.load_declarative_ldm(workspace_id, layout_root_path)
self.put_declarative_ldm(workspace_id, declarative_ldm, validator, standalone_copy)

def store_ldm_to_disk(self, workspace_id: str, path: Path = Path.cwd()) -> None:
def store_ldm_to_disk(self, workspace_id: str, path: Path = Path.cwd(), sort: bool = False) -> None:
"""Store declarative logical data model for a given workspace in directory hierarchy.
This method does not tie the LDM to the workspace and organization, thus it is recommended
for migration between organizations. If you want to backup LDM use store_declarative_ldm.
Expand All @@ -368,11 +368,13 @@ def store_ldm_to_disk(self, workspace_id: str, path: Path = Path.cwd()) -> None:
Workspace identification string e.g. "demo"
path (Path, optional):
Path to the root of the layout directory. Defaults to Path.cwd().
sort (bool, optional):
Flag if the output should be sorted before storing to disk. Default is False.

Returns:
None
"""
self.get_declarative_ldm(workspace_id).store_to_disk(path)
self.get_declarative_ldm(workspace_id).store_to_disk(path, sort=sort)

@staticmethod
def load_ldm_from_disk(path: Path = Path.cwd()) -> CatalogDeclarativeModel:
Expand Down Expand Up @@ -479,7 +481,7 @@ def load_and_put_declarative_analytics_model(self, workspace_id: str, layout_roo
self.put_declarative_analytics_model(workspace_id, declarative_analytics_model)

def store_analytics_model_to_disk(
self, workspace_id: str, path: Path = Path.cwd(), exclude: Optional[list[str]] = None
self, workspace_id: str, path: Path = Path.cwd(), exclude: Optional[list[str]] = None, sort: bool = False
) -> None:
"""Store analytics model for a given workspace in directory hierarchy.This method does not tie the declarative
analytics model to the workspace and organization, thus it is recommended for migration between workspaces.
Expand All @@ -491,12 +493,14 @@ def store_analytics_model_to_disk(
path (Path, optional):
Path to the root of the layout directory. Defaults to Path.cwd().
exclude (Optional[list[str]]):
Defines properties which should not be included in the payload. E.g.: ["ACTIVITY_INFO"]
Defines properties which should not be included in the result. E.g.: ["ACTIVITY_INFO"] – refers to createdBy, etc. Default is None.
sort (bool, optional):
Flag if the output should be sorted before storing to disk. Default is False.

Returns:
None
"""
self.get_declarative_analytics_model(workspace_id, exclude).store_to_disk(path)
self.get_declarative_analytics_model(workspace_id, exclude).store_to_disk(path, sort=sort)

@staticmethod
def load_analytics_model_from_disk(path: Path = Path.cwd()) -> CatalogDeclarativeAnalytics:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class CatalogDeclarativeAnalytics(Base):
def client_class() -> type[DeclarativeAnalytics]:
return DeclarativeAnalytics

def store_to_disk(self, workspace_folder: Path) -> None:
def store_to_disk(self, workspace_folder: Path, sort: bool = False) -> None:
if self.analytics is not None:
self.analytics.store_to_disk(workspace_folder)
self.analytics.store_to_disk(workspace_folder, sort=sort)

@classmethod
def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalytics:
Expand Down Expand Up @@ -137,7 +137,7 @@ def get_export_definition_dif(analytics_model_folder: Path) -> Path:
create_directory(folder)
return folder

def store_to_disk(self, workspace_folder: Path) -> None:
def store_to_disk(self, workspace_folder: Path, sort: bool = False) -> None:
analytics_model_folder = self.get_analytics_model_folder(workspace_folder)

analytical_dashboards_folder = self.get_analytical_dashboards_folder(analytics_model_folder)
Expand All @@ -150,28 +150,28 @@ def store_to_disk(self, workspace_folder: Path) -> None:
export_definition_folder = self.get_export_definition_dif(analytical_dashboards_folder)

for analytical_dashboard in self.analytical_dashboards:
analytical_dashboard.store_to_disk(analytical_dashboards_folder)
analytical_dashboard.store_to_disk(analytical_dashboards_folder, sort=sort)

for analytical_dashboard_extension in self.analytical_dashboard_extensions:
analytical_dashboard_extension.store_to_disk(analytical_dashboard_extensions_folder)
analytical_dashboard_extension.store_to_disk(analytical_dashboard_extensions_folder, sort=sort)

for dashboard_plugin in self.dashboard_plugins:
dashboard_plugin.store_to_disk(dashboard_plugins_folder)
dashboard_plugin.store_to_disk(dashboard_plugins_folder, sort=sort)

for filter_context in self.filter_contexts:
filter_context.store_to_disk(filter_contexts_folder)
filter_context.store_to_disk(filter_contexts_folder, sort=sort)

for metric in self.metrics:
metric.store_to_disk(metrics_folder)
metric.store_to_disk(metrics_folder, sort=sort)

for visualization_object in self.visualization_objects:
visualization_object.store_to_disk(visualization_objects_folder)
visualization_object.store_to_disk(visualization_objects_folder, sort=sort)

for attribute_hierarchy in self.attribute_hierarchies:
attribute_hierarchy.store_to_disk(attribute_hierarchy_folder)
attribute_hierarchy.store_to_disk(attribute_hierarchy_folder, sort=sort)

for export_definition in self.export_definitions:
export_definition.store_to_disk(export_definition_folder)
export_definition.store_to_disk(export_definition_folder, sort=sort)

@classmethod
def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalyticsLayer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
class CatalogAnalyticsObjectBase(Base):
id: str

def store_to_disk(self, analytics_folder: Path) -> None:
def store_to_disk(self, analytics_folder: Path, sort: bool = False) -> None:
analytics_file = analytics_folder / f"{self.id}.yaml"
write_layout_to_file(analytics_file, self.to_api().to_dict(camel_case=True))
write_layout_to_file(analytics_file, self.to_api().to_dict(camel_case=True), sort=sort)

@classmethod
def load_from_disk(cls: type[T], analytics_file: Path) -> T:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class CatalogDeclarativeDataset(Base):
def client_class() -> type[DeclarativeDataset]:
return DeclarativeDataset

def store_to_disk(self, datasets_folder: Path) -> None:
def store_to_disk(self, datasets_folder: Path, sort: bool = False) -> None:
dataset_file = datasets_folder / f"{self.id}.yaml"
write_layout_to_file(dataset_file, self.to_api().to_dict(camel_case=True))
write_layout_to_file(dataset_file, self.to_api().to_dict(camel_case=True), sort=sort)

@classmethod
def load_from_disk(cls, dataset_file: Path) -> CatalogDeclarativeDataset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class CatalogDeclarativeDatasetExtension(Base):
def client_class() -> type[DeclarativeDatasetExtension]:
return DeclarativeDatasetExtension

def store_to_disk(self, dataset_extension_folder: Path) -> None:
def store_to_disk(self, dataset_extension_folder: Path, sort: bool = False) -> None:
dataset_extension_file = dataset_extension_folder / f"{self.id}.yaml"
write_layout_to_file(dataset_extension_file, self.to_api().to_dict(camel_case=True))
write_layout_to_file(dataset_extension_file, self.to_api().to_dict(camel_case=True), sort=sort)

@classmethod
def load_from_disk(cls, dataset_extension_file: Path) -> "CatalogDeclarativeDatasetExtension":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class CatalogDeclarativeDateDataset(Base):
def client_class() -> type[DeclarativeDateDataset]:
return DeclarativeDateDataset

def store_to_disk(self, date_instances_folder: Path) -> None:
def store_to_disk(self, date_instances_folder: Path, sort: bool = False) -> None:
date_instance_file = date_instances_folder / f"{self.id}.yaml"
write_layout_to_file(date_instance_file, self.to_api().to_dict(camel_case=True))
write_layout_to_file(date_instance_file, self.to_api().to_dict(camel_case=True), sort=sort)

@classmethod
def load_from_disk(cls, date_instance_file: Path) -> CatalogDeclarativeDateDataset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class CatalogDeclarativeModel(Base):
def client_class() -> type[DeclarativeModel]:
return DeclarativeModel

def store_to_disk(self, workspace_folder: Path) -> None:
def store_to_disk(self, workspace_folder: Path, sort: bool = False) -> None:
if self.ldm is not None:
self.ldm.store_to_disk(workspace_folder)
self.ldm.store_to_disk(workspace_folder, sort=sort)

@classmethod
def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeModel:
Expand Down Expand Up @@ -106,20 +106,20 @@ def create_dataset_extensions_folder(ldm_folder: Path) -> Path:
create_directory(folder)
return folder

def store_to_disk(self, workspace_folder: Path) -> None:
def store_to_disk(self, workspace_folder: Path, sort: bool = False) -> None:
ldm_folder = self.create_ldm_folder(workspace_folder)
datasets_folder = self.create_datasets_folder(ldm_folder)
date_instances_folder = self.create_date_instances_folder(ldm_folder)

for dataset in self.datasets:
dataset.store_to_disk(datasets_folder)
dataset.store_to_disk(datasets_folder, sort=sort)
for date_instance in self.date_instances:
date_instance.store_to_disk(date_instances_folder)
date_instance.store_to_disk(date_instances_folder, sort=sort)
# Note: should be defaulted to an empty list in the future
if self.dataset_extensions:
dataset_extensions_folder = self.create_dataset_extensions_folder(ldm_folder)
for dataset_extension in self.dataset_extensions:
dataset_extension.store_to_disk(dataset_extensions_folder)
dataset_extension.store_to_disk(dataset_extensions_folder, sort=sort)

@classmethod
def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeLdm:
Expand Down
Loading
Loading