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
2 changes: 1 addition & 1 deletion dnastack/cli/commands/workbench/workflows/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def create_workflow(context: Optional[str],

docs: https://docs.omics.ai/docs/workflows-create
"""
workflows_client = get_workflow_client(context, endpoint_id, namespace)
workflows_client = get_workflow_client(context, endpoint_id, namespace, global_action=global_action)
# Add entrypoint to workflow_files

workflow_files_list: List[Path] = [Path(f.value()) for f in workflow_file]
Expand Down
16 changes: 12 additions & 4 deletions dnastack/cli/commands/workbench/workflows/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from dnastack.cli.commands.workbench.utils import _populate_workbench_endpoint
from dnastack.cli.commands.workbench.utils import get_user_client
from dnastack.cli.helpers.client_factory import ConfigurationBasedClientFactory
from dnastack.client.workbench.workflow.client import WorkflowClient
from dnastack.client.workbench.workflow.client import WorkflowClient, GLOBAL_NAMESPACE
from dnastack.client.workbench.workflow.models import WorkflowFile, WorkflowFileType
from dnastack.common.json_argument_parser import FileOrValue
from dnastack.http.session import JsonPatch
Expand Down Expand Up @@ -46,10 +46,18 @@ def __init__(self, message: str):

def get_workflow_client(context_name: Optional[str] = None,
endpoint_id: Optional[str] = None,
namespace: Optional[str] = None) -> WorkflowClient:
namespace: Optional[str] = None,
global_action: bool = False) -> WorkflowClient:
if not namespace:
user_client = get_user_client(context_name=context_name, endpoint_id=endpoint_id)
namespace = user_client.get_user_config().default_namespace
if global_action:
# Platform admins have no namespace. The workflow-service ignores the path
# namespace for global (admin) operations and routes via the X-Global-Namespace
# header, so a non-empty placeholder is enough to keep the URL well-formed
# without a (failing) users/me lookup.
namespace = GLOBAL_NAMESPACE
else:
user_client = get_user_client(context_name=context_name, endpoint_id=endpoint_id)
namespace = user_client.get_user_config().default_namespace

factory: ConfigurationBasedClientFactory = container.get(ConfigurationBasedClientFactory)
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def add_version(context: Optional[str],

docs: https://docs.omics.ai/docs/workflows-versions-create
"""
workflows_client = get_workflow_client(context, endpoint_id, namespace)
workflows_client = get_workflow_client(context, endpoint_id, namespace, global_action=global_action)

workflow_files_list: List[Path] = [Path(f.value()) for f in workflow_file]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def create_workflow_defaults(context: Optional[str],
"""
Create a default for a workflow
"""
client = get_workflow_client(context_name=context, endpoint_id=endpoint_id, namespace=namespace)
client = get_workflow_client(context_name=context, endpoint_id=endpoint_id, namespace=namespace,
global_action=global_action)
parsed = values.parsed_value()
selector = WorkflowDefaultsSelector(engine=engine, provider=provider, region=region)
workflow_defaults = WorkflowDefaultsCreateRequest(id=default_id, name=name, selector=selector, values=parsed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def create(context: Optional[str] = None,
workflow_client = get_workflow_client(
context_name=context,
endpoint_id=endpoint_id,
namespace=namespace
namespace=namespace,
global_action=global_action
)

# Parse and resolve dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def add_workflow_transformation(context: Optional[str],
labels: List[str],
global_action: bool = False):
"""Create a new workflow transformation"""
client = get_workflow_client(context_name=context, endpoint_id=endpoint_id, namespace=namespace)
client = get_workflow_client(context_name=context, endpoint_id=endpoint_id, namespace=namespace,
global_action=global_action)

workflow_transformation = WorkflowTransformationCreate(
id=transformation_id,
Expand Down
3 changes: 2 additions & 1 deletion dnastack/client/workbench/workbench_user_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
class WorkbenchUser(BaseModel):
email: str
full_name: Optional[str] = None
default_namespace: str
# Platform admins have an account but no namespace, so this can be absent/null.
default_namespace: Optional[str] = None


class Namespace(BaseModel):
Expand Down
5 changes: 5 additions & 0 deletions dnastack/client/workbench/workflow/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

_GLOBAL_NAMESPACE_HEADERS = {'X-Global-Namespace': 'true', 'X-Admin-Only-Action': 'true'}

# Placeholder path segment for global (platform-admin) operations. The workflow-service
# ignores the namespace in the path when the global headers are present, so any non-empty,
# URL-safe value works; it only keeps the request URL well-formed.
GLOBAL_NAMESPACE = 'global'


class WorkflowDefaultsListResultLoader(WorkbenchResultLoader):
def __init__(self,
Expand Down
Loading
Loading