Skip to content

Add simple Create Project Structure web action #1193

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

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0a207ad
Add simple Create Project Structure launcher action
BigRoy Jun 20, 2024
905241f
Cosmetics
BigRoy Jun 20, 2024
fbd2735
Cosmetics
BigRoy Jun 20, 2024
18f750f
Update client/ayon_core/plugins/actions/create_project_folder_structu…
BigRoy Jun 21, 2024
29205b7
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Jun 27, 2024
1747af6
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Jun 28, 2024
338e6b3
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Jul 29, 2024
240b2b9
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Sep 2, 2024
23f25a0
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
MustafaJafar Sep 10, 2024
6b15de5
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
MustafaJafar Sep 23, 2024
da28af5
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Oct 4, 2024
56fb5c4
Rename action to Create Project Folders
BigRoy Oct 4, 2024
8383fde
Hide action if setting is empty
BigRoy Oct 4, 2024
5aa7e9c
Add description to setting
BigRoy Oct 4, 2024
5065e0e
Explicit description to describe diff between ftrack and launcher
BigRoy Oct 4, 2024
f0cdeca
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Feb 18, 2025
ed8d833
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Mar 4, 2025
baaa075
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Mar 5, 2025
1cf0cc5
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
BigRoy Mar 10, 2025
d5b2642
implement `createprojectstructure` cli action.
MustafaJafar Mar 13, 2025
4f6ea87
Implement `Create Project Folder Structure` web action
MustafaJafar Mar 13, 2025
6c65074
remove `CreateProjectFoldersAction` launcher action.
MustafaJafar Mar 13, 2025
ff19ee3
Merge branch 'develop' into enhancement/web_action_action_to_create_f…
MustafaJafar Mar 13, 2025
5e54ebc
Merge branch 'develop' into enhancement/web_action_action_to_create_f…
MustafaJafar Mar 14, 2025
8b50118
move the function above private functions
MustafaJafar Mar 19, 2025
7cf02d9
update help of project argument in create project structure.
MustafaJafar Mar 19, 2025
71819f1
refactor dunction name to `create_project_structure`
MustafaJafar Mar 19, 2025
3636f5d
fix command argument
MustafaJafar Mar 19, 2025
1331167
update identifier prefix
MustafaJafar Mar 19, 2025
4510982
update function type hints and docstring
MustafaJafar Mar 19, 2025
ff76178
only import the needed function
MustafaJafar Mar 19, 2025
207f6d8
move import to the function.
MustafaJafar Mar 19, 2025
0ec82bd
check project name when adding or executing `create_project_structure`
MustafaJafar Apr 7, 2025
7a7f4b4
use logger from backend with fallback to nxtools
MustafaJafar Apr 7, 2025
148110b
Merge branch 'develop' into enhancement/launcher_action_to_create_fol…
MustafaJafar Apr 7, 2025
01069f6
update poetry lock
MustafaJafar Apr 7, 2025
be8d654
Merge branch 'develop' into enhancement/web_action_action_to_create_f…
MustafaJafar Apr 15, 2025
0fdff60
remove the poetry.lock - again
MustafaJafar Apr 15, 2025
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
25 changes: 24 additions & 1 deletion client/ayon_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)



@click.group(invoke_without_command=True)
@click.pass_context
@click.option("--use-staging", is_flag=True,
Expand Down Expand Up @@ -237,6 +236,30 @@ def version(build):
print(os.environ["AYON_VERSION"])


@main_cli.command()
@click.option(
"--project",
type=str,
help="Project name",
required=True)
def create_project_structure(
project,
):
"""Create project folder structure as defined in setting
`ayon+settings://core/project_folder_structure`

Args:
project (str): The name of the project for which you
want to create its additional folder structure.

"""

from ayon_core.pipeline.project_folders import create_project_folders

print(f">>> Creating project folder structure for project '{project}'.")
create_project_folders(project)


def _set_global_environments() -> None:
"""Set global AYON environments."""
# First resolve general environment
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mdx-gh-links = "^0.4"
pymdown-extensions = "^10.14.3"
mike = "^2.1.3"
mkdocstrings-shell = "^1.0.2"
nxtools = "^1.6"


[tool.ruff]
Expand Down
66 changes: 66 additions & 0 deletions server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from typing import Any

from ayon_server.addons import BaseServerAddon
from ayon_server.actions import (
ActionExecutor,
ExecuteResponseModel,
SimpleActionManifest,
)
try:
from ayon_server.logging import logger
except ImportError:
from nxtools import logging as logger

from .settings import (
CoreSettings,
Expand All @@ -9,6 +18,9 @@
)


IDENTIFIER_PREFIX = "core"


class CoreAddon(BaseServerAddon):
settings_model = CoreSettings

Expand All @@ -26,3 +38,57 @@ async def convert_settings_overrides(
return await super().convert_settings_overrides(
source_version, overrides
)

async def get_simple_actions(
self,
project_name: str | None = None,
variant: str = "production",
) -> list[SimpleActionManifest]:
"""Return a list of simple actions provided by the addon"""
output = []

if project_name:
# Add 'Create Project Folder Structure' action to folders.
output.append(
SimpleActionManifest(
identifier=f"{IDENTIFIER_PREFIX}.createprojectstructure",
label="Create Project Folder Structure",
icon={
"type": "material-symbols",
"name": "create_new_folder",
},
order=100,
entity_type="folder",
entity_subtypes=None,
allow_multiselection=False,
)
)

return output

async def execute_action(
self,
executor: ActionExecutor,
) -> ExecuteResponseModel:
"""Execute webactions."""

project_name = executor.context.project_name

if executor.identifier == \
f"{IDENTIFIER_PREFIX}.create_project_structure":

if not project_name:
logger.error(
f"Can't execute {executor.identifier} because"
" of missing project name."
)
return

return await executor.get_launcher_action_response(
args=[
"create-project-structure",
"--project", project_name,
]
)

logger.debug(f"Unknown action: {executor.identifier}")
9 changes: 9 additions & 0 deletions server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ class CoreSettings(BaseSettingsModel):
"{}",
widget="textarea",
title="Project folder structure",
description=(
"Defines project folders to create on 'Create project folders'."
"\n\n"
"- In the launcher, this only creates the folders on disk and "
" when the setting is empty it will be hidden from users in the"
" launcher.\n"
"- In `ayon-ftrack` this will create the folders on disk **and**"
" will also create ftrack entities. It is never hidden there."
),
section="---"
)
project_environments: str = SettingsField(
Expand Down
Loading