Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Ingest - fallback to folder name if folder path is not complete #28

Closed
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
14 changes: 12 additions & 2 deletions client/ayon_traypublisher/plugins/create/create_csv_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,23 @@ def _get_data_from_csv(
product_item.folder_path
for product_item in product_items_by_name.values()
}
folder_ids_by_path: Dict[str, str] = {
folder_ids: Dict[str, str] = {
folder_entity["path"]: folder_entity["id"]
for folder_entity in ayon_api.get_folders(
project_name, folder_paths=folder_paths, fields={"id", "path"}
)
}
missing_paths: Set[str] = folder_paths - set(folder_ids_by_path.keys())
missing_paths: Set[str] = folder_paths - set(folder_ids.keys())
if missing_paths:
folder_ids_by_name: Dict[str, str] = {
folder_entity["path"]: folder_entity["id"]
for folder_entity in ayon_api.get_folders(
project_name,
folder_names=missing_paths, fields={"id", "path"}
)
}
folder_ids.update(folder_ids_by_name)
Comment on lines +461 to +469
Copy link
Contributor

@BigRoy BigRoy Nov 12, 2024

Choose a reason for hiding this comment

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

I think this is interesting, but I also think we should exclude any that already have / inside the folder paths to ensure we disallow implicitly matching another folder by name if a folder path was initially passed.

Also, I think we may be better off being even more explicit and allowing a dedicated folder name column instead of folder path so that if a user uses that it's clear that the column allows matching any existing folder?

@jakubjezek001 thoughts?


Note also that this code is buggy - because below we're also using folder_ids_by_path to query the task entities - however those found by folder name are not included in that lookup.

Copy link
Member

Choose a reason for hiding this comment

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

The folder path column should be sufficient. Let's not add another column if the information can be extracted from the folder path.

missing_paths: Set[str] = folder_paths - set(folder_ids.keys())
if missing_paths:
ending = "" if len(missing_paths) == 1 else "s"
joined_paths = "\n".join(sorted(missing_paths))
Expand Down
Loading