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 .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: pre-commit/action@v3.0.0

- name: Run tests
run: poetry run pytest -vvv --exitfirst --cov=app --cov-report=term --cov-report=xml --cov-fail-under=54
run: poetry run pytest -vvv --exitfirst --cov=app --cov-report=term --cov-report=xml --cov-fail-under=60

- name: Coverage report comment
uses: mishakav/pytest-coverage-comment@v1.1.42
Expand Down
4 changes: 2 additions & 2 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Copyright (C) 2022 Indoc Research
Copyright (C) 2022 Indoc Systems

Contact Indoc Research for any questions regarding the use of this source code.
Contact Indoc Systems for any questions regarding the use of this source code.
4 changes: 2 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (C) 2022-2023 Indoc Research
# Copyright (C) 2022-2023 Indoc Systems
#
# Contact Indoc Research for any questions regarding the use of this source code.
# Contact Indoc Systems for any questions regarding the use of this source code.
4 changes: 2 additions & 2 deletions app/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (C) 2022-2023 Indoc Research
# Copyright (C) 2022-2023 Indoc Systems
#
# Contact Indoc Research for any questions regarding the use of this source code.
# Contact Indoc Systems for any questions regarding the use of this source code.
4 changes: 2 additions & 2 deletions app/commands/container_registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2022-2023 Indoc Research
# Copyright (C) 2022-2023 Indoc Systems
#
# Contact Indoc Research for any questions regarding the use of this source code.
# Contact Indoc Systems for any questions regarding the use of this source code.

import click

Expand Down
4 changes: 2 additions & 2 deletions app/commands/dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2022-2023 Indoc Research
# Copyright (C) 2022-2023 Indoc Systems
#
# Contact Indoc Research for any questions regarding the use of this source code.
# Contact Indoc Systems for any questions regarding the use of this source code.

import click
import questionary
Expand Down
72 changes: 14 additions & 58 deletions app/commands/entry_point.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright (C) 2022-2023 Indoc Research
# Copyright (C) 2022-2023 Indoc Systems
#
# Contact Indoc Research for any questions regarding the use of this source code.
# Contact Indoc Systems for any questions regarding the use of this source code.

import os

import click

from app.services.user_authentication.decorator import require_config
from app.services.user_authentication.decorator import require_login_session

from .container_registry import create_project
Expand All @@ -25,29 +24,17 @@
from .file import file_resume

# Import custom commands
from .hpc import hpc_auth
from .hpc import hpc_get_node
from .hpc import hpc_get_partition
from .hpc import hpc_job_info
from .hpc import hpc_job_submit
from .hpc import hpc_list_nodes
from .hpc import hpc_list_partitions
from .kg_resource import kg_resource
from .project import project_list_all
from .use_config import set_env
from .user import login
from .user import logout

hpc_enabled = os.environ.get('PILOT_CLI_HPC_ENABLED', 'false') == 'true'
kg_enabled = os.environ.get('PILOT_CLI_KG_ENABLED', 'false') == 'true'
container_registry_enabled = os.environ.get('PILOT_CLI_CONTAINER_REGISTRY_ENABLED', 'false') == 'true'


def command_groups():
commands = ['file', 'user', 'use_config', 'project', 'dataset', 'container_registry']
if hpc_enabled:
commands.append('hpc')
if kg_enabled:
commands.append('kg_resource')
commands = ['file', 'user', 'project', 'dataset']
if container_registry_enabled:
commands.append('container_registry')
return commands


Expand All @@ -57,43 +44,28 @@ def entry_point():


@entry_point.group(name='project')
@require_config
@require_login_session
def project_group():
pass


@entry_point.group(name='dataset')
@require_config
@require_login_session
def dataset_group():
pass


@entry_point.group(name='file')
@require_config
@require_login_session
def file_group():
pass


@entry_point.group(name='user')
@require_config
def user_group():
pass


@entry_point.group(name='use_config')
def config_group():
pass


@entry_point.group(name='container_registry')
@require_config
def cr_group():
pass


file_group.add_command(file_put)
file_group.add_command(file_check_manifest)
file_group.add_command(file_export_manifest)
Expand All @@ -106,32 +78,16 @@ def cr_group():
dataset_group.add_command(dataset_list)
dataset_group.add_command(dataset_show_detail)
dataset_group.add_command(dataset_download)
cr_group.add_command(list_projects)
cr_group.add_command(list_repositories)
cr_group.add_command(create_project)
cr_group.add_command(get_secret)
cr_group.add_command(invite_member)
config_group.add_command(set_env)

# Custom commands
if hpc_enabled:

@entry_point.group(name='hpc')
def hpc_group():
pass

hpc_group.add_command(hpc_auth)
hpc_group.add_command(hpc_job_submit)
hpc_group.add_command(hpc_job_info)
hpc_group.add_command(hpc_list_nodes)
hpc_group.add_command(hpc_get_node)
hpc_group.add_command(hpc_list_partitions)
hpc_group.add_command(hpc_get_partition)

if kg_enabled:
if container_registry_enabled:

@entry_point.group(name='kg_resource')
def kg_resource_group():
@entry_point.group(name='container_registry')
def cr_group():
pass

kg_resource_group.add_command(kg_resource)
cr_group.add_command(list_projects)
cr_group.add_command(list_repositories)
cr_group.add_command(create_project)
cr_group.add_command(get_secret)
cr_group.add_command(invite_member)
13 changes: 10 additions & 3 deletions app/commands/file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2022-2023 Indoc Research
# Copyright (C) 2022-2023 Indoc Systems
#
# Contact Indoc Research for any questions regarding the use of this source code.
# Contact Indoc Systems for any questions regarding the use of this source code.

import json
import os
Expand Down Expand Up @@ -245,9 +245,16 @@ def file_resume(**kwargs): # noqa: C901
# are rather similar with the input
validate_upload_event(resumable_manifest)

# print(resumable_manifest)
resume_upload(resumable_manifest, thread)

# since only file upload can attach manifest, take the first file object
srv_manifest = SrvFileManifests()
item_id = next(iter(resumable_manifest.get('file_objects')))
attribute = resumable_manifest.get('attributes')
zone = resumable_manifest.get('zone')
srv_manifest.attach_manifest(attribute, item_id, zone) if attribute else None
message_handler.SrvOutPutHandler.all_file_uploaded()


def validate_upload_event(event):
"""validate upload request, raise error when filed."""
Expand Down
157 changes: 0 additions & 157 deletions app/commands/hpc.py

This file was deleted.

23 changes: 0 additions & 23 deletions app/commands/kg_resource.py

This file was deleted.

Loading