Skip to content

Conversation

@benkeanna
Copy link
Contributor

No description provided.

Comment on lines 169 to 172
if path_to_csv is None and workspace_ids is None:
raise ValueError(
f"Path to CSV is required for this input type: {input_type.value}"
f"Path to CSV or list of workspace IDs is required for this input type: {input_type.value}"
)
elif path_to_csv is not None and workspace_ids is not None:
raise ValueError(
f"Path to CSV and list of workspace IDs are mutually exclusive for this input type: {input_type.value}"
)
Copy link
Contributor

@hkad98 hkad98 Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition can be simplified.

# Both or none of them is specified.
if (path_to_csv is None) == (workspace_ids is None):

Comment on lines 179 to 188
if input_type == InputType.LIST_OF_WORKSPACES:
return self.csv_reader.read_backup_csv(path_to_csv)
if path_to_csv is not None:
return self.csv_reader.read_backup_csv(path_to_csv)
elif workspace_ids is not None:
return workspace_ids
else:
raise ValueError(
f"Path to CSV or list of workspace IDs is required for this input type: {input_type.value}"
)
else:
# For hierarchy backup, we read the CSV and treat it as a list of
# parent workspace IDs. Then we retrieve the children of each parent,
# including their children, and so on. The parent workspaces are
# also included in the backup.
list_of_parents = self.csv_reader.read_backup_csv(path_to_csv)
if path_to_csv is not None:
list_of_parents = self.csv_reader.read_backup_csv(
path_to_csv
)
elif workspace_ids is not None:
list_of_parents = workspace_ids
else:
raise ValueError(
f"Path to CSV or list of workspace IDs is required for this input type: {input_type.value}"
)
list_of_children: list[str] = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposed simplification:

list_of_parents = self.csv_reader.read_backup_csv(path_to_csv) if path_to_csv is not None else workspace_ids

if input_type == InputType.LIST_OF_WORKSPACES:
    return list_of_parents
    
 # This is HIERARCHY, continue with the existing impl

@benkeanna benkeanna force-pushed the aben/backup-from-list branch 2 times, most recently from 5dc4885 to 037ba44 Compare August 13, 2025 13:59
@benkeanna benkeanna force-pushed the aben/backup-from-list branch from 037ba44 to 31aeaf1 Compare August 14, 2025 05:38
@benkeanna benkeanna merged commit 591a595 into master Aug 14, 2025
9 checks passed
@benkeanna benkeanna deleted the aben/backup-from-list branch August 14, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants