Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ba7ed8e
merge back with next preminor
Sep 27, 2023
7a05c06
update version in user help page
Sep 27, 2023
879d6a3
Merge pull request #100 from PilotDataPlatform/mb/staging-release-202…
andricDu Sep 27, 2023
d65412a
PILOT-3589: use the item id for the presigned url api (#101)
colorzzr Oct 3, 2023
3dcdd2e
PILOT-3921: Update the ARCHIVED to TRASHED for metadata item status
QXgu Oct 13, 2023
4b889d2
Update the unit test
QXgu Oct 17, 2023
3c5106d
Merge pull request #104 from PilotDataPlatform/PILOT-3921
QXgu Oct 19, 2023
c5a0d9d
PILOT-3931: Added DELETED ItemStatus.
vadimsoltan Oct 19, 2023
054b808
Merge pull request #106 from PilotDataPlatform/PILOT-3931
vadimsoltan Oct 20, 2023
96eb810
update the error message when user abort folder merging
Nov 7, 2023
ee426d5
update command sync to download
Nov 7, 2023
8bacc7e
bumpup the version
Nov 7, 2023
06ac395
Merge pull request #107 from PilotDataPlatform/patch20231107
andricDu Nov 8, 2023
f09613a
fixup the exit does not defined when abort folder merging.
Nov 9, 2023
e48eaf2
remove the unnecessary item_type in the file search api
Nov 9, 2023
23d28aa
rever the changes
Nov 9, 2023
05b1772
the cli version will require the poetry to install the root
Nov 17, 2023
40004a6
PILOT-3643: Fix issue with multiprocessing in pyinstaller (#109)
vmoshynskyi Nov 20, 2023
b2db5f2
Pilot 4067: fixup the core zone upload message and abort error handle…
colorzzr Nov 22, 2023
6af654f
prepare the release branch
Nov 23, 2023
f377927
use correct version
Nov 23, 2023
016bb2a
Merge branch 'main' into rc/staging-release-20231123
colorzzr Nov 24, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
run: poetry install --no-interaction --no-root
run: poetry install --no-interaction

- name: Build default binary
run: poetry run pyinstaller -F --distpath ./app/bundled_app/linux --specpath ./app/build/linux --workpath ./app/build/linux --paths=./.venv/lib/python3.9/site-packages ./app/pilotcli.py -n ${{ github.sha }}
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
run: poetry install --no-interaction --no-root
run: poetry install --no-interaction

- name: Build binary
run: poetry run pyinstaller -F --distpath ./app/bundled_app/macos --specpath ./app/build/macos --workpath ./app/build/macos --paths=./.venv/lib/python3.9/site-packages ./app/pilotcli.py -n ${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
run: poetry install --no-interaction --no-root
run: poetry install --no-interaction

- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.0
Expand Down
22 changes: 17 additions & 5 deletions app/commands/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import json
import os
from sys import exit

import click
from click.exceptions import Abort

import app.services.output_manager.help_page as file_help
import app.services.output_manager.message_handler as message_handler
Expand Down Expand Up @@ -125,16 +127,26 @@ def file_put(**kwargs): # noqa: C901
zone = get_zone(zone) if zone else AppConfig.Env.green_zone.lower()

toc = customized_error_msg(ECustomizedError.TOU_CONTENT).replace(' ', '...')
if zone.lower() == AppConfig.Env.core_zone.lower() and click.confirm(fit_terminal_width(toc), abort=True):
pass
try:
if zone.lower() == AppConfig.Env.core_zone.lower() and click.confirm(fit_terminal_width(toc), abort=True):
pass
except Abort:
message_handler.SrvOutPutHandler.cancel_upload()
exit(1)

# check if user input at least one file/folder
if len(paths) == 0:
SrvErrorHandler.customized_handle(ECustomizedError.INVALID_PATHS, True)

# check if the manifest file exists
if os.path.exists(output_path):
click.confirm(customized_error_msg(ECustomizedError.MANIFEST_OF_FOLDER_FILE_EXIST) % (output_path), abort=True)
try:
if os.path.exists(output_path):
click.confirm(
customized_error_msg(ECustomizedError.MANIFEST_OF_FOLDER_FILE_EXIST) % (output_path), abort=True
)
except Abort:
message_handler.SrvOutPutHandler.cancel_upload()
exit(1)

project_path = click.prompt('ProjectCode') if not project_path else project_path
project_code, target_folder = identify_target_folder(project_path)
Expand Down Expand Up @@ -349,7 +361,7 @@ def file_list(paths, zone, page, page_size, detached):
srv_list.list_files_with_pagination(paths, zone, page, page_size)


@click.command(name='sync')
@click.command(name='download')
@click.argument('paths', type=click.STRING, nargs=-1)
@click.argument('output_path', type=click.Path(exists=True), nargs=1)
@click.option(
Expand Down
3 changes: 3 additions & 0 deletions app/pilotcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# Contact Indoc Systems for any questions regarding the use of this source code.

from multiprocessing import freeze_support

import click
import requests

Expand Down Expand Up @@ -38,4 +40,5 @@ def cli():


if __name__ == '__main__':
freeze_support() # Add support for multiprocessing after bundling with PyInstaller
cli()
6 changes: 3 additions & 3 deletions app/resources/custom_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class Error:
'USER_NOT_FOUND': 'User not found.',
'CONTAINER_REGISTRY_OTHER': 'Encountered an error when interacting with container registry.',
'TOU_CONTENT': (
'You are about to transfer data directly to the PILOT Core! '
'In accordance with the PILOT Terms of Use, please confirm that you have made your best efforts '
'You are about to transfer data directly to the Pilot Core. '
'In accordance with the Pilot Terms of Use, please confirm that you have made your best efforts '
'to pseudonymize or anonymize the data and that you have the legal authority to transfer and make this '
'data available for dissemination and use within the PILOT. If you need to process the data to remove '
'data available for dissemination and use within Pilot. If you need to process the data to remove '
'sensitive identifiers, please cancel this transfer and upload the data to the Green Room to perform '
'these actions.'
),
Expand Down
4 changes: 3 additions & 1 deletion app/resources/custom_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#
# Contact Indoc Systems for any questions regarding the use of this source code.

import pkg_resources


class HelpPage:
page = {
'update': {
'version': '2.7.4',
'version': pkg_resources.get_distribution('app').version,
'1': 'Add new feature for folder merging',
'2': 'Secure the config file',
'3': 'Optimize logic, input and error message',
Expand Down
21 changes: 17 additions & 4 deletions app/services/file_manager/file_upload/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import time
import zipfile
from multiprocessing.pool import ThreadPool
from sys import exit
from typing import Any
from typing import Dict
from typing import List
from typing import Tuple

import click
from click.exceptions import Abort

import app.services.logger_services.log_functions as logger
import app.services.output_manager.message_handler as mhandler
Expand Down Expand Up @@ -91,8 +93,14 @@ def assemble_path(
# find the longest existing folder as parent folder
# if user input a path that need to create some folders
if not res.get('result'):
try:
click.confirm(customized_error_msg(ECustomizedError.CREATE_FOLDER_IF_NOT_EXIST), abort=True)
except Abort:
mhandler.SrvOutPutHandler.cancel_upload()
exit(1)

# stop scaning and use the current folder as parent folder
current_folder_node = folder_path
click.confirm(customized_error_msg(ECustomizedError.CREATE_FOLDER_IF_NOT_EXIST), abort=True)
create_folder_flag = True
break
else:
Expand Down Expand Up @@ -194,9 +202,14 @@ def simple_upload( # noqa: C901
elif len(duplicated_file) > 0:
mhandler.SrvOutPutHandler.file_duplication_check_success()
duplicate_warning_format = '\n'.join(duplicated_file)
click.confirm(
customized_error_msg(ECustomizedError.UPLOAD_SKIP_DUPLICATION) % (duplicate_warning_format), abort=True
)
try:
click.confirm(
customized_error_msg(ECustomizedError.UPLOAD_SKIP_DUPLICATION) % (duplicate_warning_format),
abort=True,
)
except Abort:
mhandler.SrvOutPutHandler.cancel_upload()
exit(1)

# here is list of pre upload result. We decided to call pre upload api by batch
pre_upload_infos = []
Expand Down
6 changes: 4 additions & 2 deletions app/services/file_manager/file_upload/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ class ItemStatus(str, Enum):
Enum type for item status where:
- REGISTERED means file is created by upload service but not complete yet. either in progress or fail.
- ACTIVE means file uploading is complete.
- ARCHIVED means the file has been deleted
- TRASHED means the file has been moved to the trash bin.
- DELETED means the file has been permanently deleted.
The status will be stored at metadata table.
"""

REGISTERED = 'REGISTERED'
ACTIVE = 'ACTIVE'
ARCHIVED = 'ARCHIVED'
TRASHED = 'TRASHED'
DELETED = 'DELETED'

def __str__(self):
return self.name
Expand Down
2 changes: 1 addition & 1 deletion app/services/file_manager/file_upload/upload_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def upload_chunk(self, file_object: FileObject, chunk_number: int, chunk: str, e
# request upload service to generate presigned url for the chunk
params = {
'bucket': self.bucket,
'key': file_object.object_path,
'key': file_object.item_id,
'upload_id': file_object.resumable_id,
'chunk_number': chunk_number,
}
Expand Down
4 changes: 4 additions & 0 deletions app/services/output_manager/message_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def start_uploading(filename):
"""e.g. Start Uploading: ./test_file."""
logger.info(f'Starting upload of: {filename}')

@staticmethod
def cancel_upload():
logger.warning('Upload cancelled.')

@staticmethod
def start_requests():
"""e.g. start requests."""
Expand Down
2 changes: 1 addition & 1 deletion app/utils/aggregated.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_file_info_by_geid(geid: list):


def fit_terminal_width(string_to_format):
string_to_format = string_to_format.split('...')
string_to_format = string_to_format.rsplit('...')
current_len = 0
sentence = ''
terminal_width = shutil.get_terminal_size().columns
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "app"
version = "2.7.4"
version = "2.8.5"
description = "This service is designed to support pilot platform"
authors = ["Indoc Systems"]

Expand Down
2 changes: 1 addition & 1 deletion tests/app/commands/test_entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_file_commands(user_login_true):
'upload': file_put,
'attribute-list': file_check_manifest,
'attribute-export': file_export_manifest,
'sync': file_download,
'download': file_download,
'resume': file_resume,
}
file_commands_object = entry_point.commands.get('file')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/utils/test_aggregated.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_search_file_should_return_200(requests_mock, mocker):
'parent': 'parent-id',
'parent_path': 'folder1',
'restore_path': None,
'archived': False,
'status': 'ACTIVE',
'type': 'file',
'zone': 0,
'name': 'test-file',
Expand All @@ -42,7 +42,7 @@ def test_search_file_should_return_200(requests_mock, mocker):
'parent': 'parent-id',
'parent_path': 'folder1',
'restore_path': None,
'archived': False,
'status': 'ACTIVE',
'type': 'file',
'zone': 0,
'name': 'test-file',
Expand Down