cloudos-cli 2.35.0__tar.gz → 2.36.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/PKG-INFO +40 -17
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/README.md +39 -16
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/__main__.py +104 -3
- cloudos_cli-2.36.0/cloudos_cli/_version.py +1 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/datasets/datasets.py +33 -3
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/utils/__init__.py +1 -1
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/utils/requests.py +35 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli.egg-info/PKG-INFO +40 -17
- cloudos_cli-2.35.0/cloudos_cli/_version.py +0 -1
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/LICENSE +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/clos.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/configure/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/configure/configure.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/datasets/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/import_wf/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/import_wf/import_wf.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/jobs/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/jobs/job.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/queue/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/queue/queue.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/utils/cloud.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/utils/details.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/utils/errors.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli/utils/resources.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli.egg-info/SOURCES.txt +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli.egg-info/dependency_links.txt +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli.egg-info/entry_points.txt +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli.egg-info/requires.txt +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/cloudos_cli.egg-info/top_level.txt +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/setup.cfg +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/setup.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/tests/__init__.py +0 -0
- {cloudos_cli-2.35.0 → cloudos_cli-2.36.0}/tests/functions_for_pytest.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudos_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.36.0
|
|
4
4
|
Summary: Python package for interacting with CloudOS
|
|
5
5
|
Home-page: https://github.com/lifebit-ai/cloudos-cli
|
|
6
6
|
Author: David Piñeyro
|
|
@@ -1013,6 +1013,38 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
1013
1013
|
--workspace-id $WORKSPACE_ID \
|
|
1014
1014
|
--project-name $PROJEC_NAME
|
|
1015
1015
|
```
|
|
1016
|
+
|
|
1017
|
+
#### Copying files and folders
|
|
1018
|
+
|
|
1019
|
+
Files and folders can be copied **from** anywhere in the project **to** `Data` or any of its subfolders programmatically (i.e `Data`, `Data/folder/file.txt`).
|
|
1020
|
+
|
|
1021
|
+
1. The copy can happen **within the same project** running the following command:
|
|
1022
|
+
```
|
|
1023
|
+
cloudos datasets cp <souce_path> <destination_path> --profile <profile name>
|
|
1024
|
+
```
|
|
1025
|
+
where the source project as well as the destination one is the one defined in the profile.
|
|
1026
|
+
|
|
1027
|
+
2. The move can also happen **across different projects** within the same workspace by running the following command
|
|
1028
|
+
```
|
|
1029
|
+
cloudos datasets cp <source_path> <destiantion_path> --profile <profile_name> --destination-project-name <project_name>
|
|
1030
|
+
```
|
|
1031
|
+
In this case, only the source project is the one specified in the profile.
|
|
1032
|
+
|
|
1033
|
+
Any of the `source_path` must be a full path; any `destination_path` must be a path starting with `Data` and finishing with the folder where to move the file/folder. An example of such command is:
|
|
1034
|
+
|
|
1035
|
+
```
|
|
1036
|
+
cloudos datasets cp AnalysesResults/my_analysis/results/my_plot.png Data/plots
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
Please, note that in the above example a preconfigured profile has been used. If no profile is provided and there is no default profile, the user will need to also provide the following flags
|
|
1040
|
+
```bash
|
|
1041
|
+
--cloudos-url $CLOUDOS \
|
|
1042
|
+
--apikey $MY_API_KEY \
|
|
1043
|
+
--workspace-id $WORKSPACE_ID \
|
|
1044
|
+
--project-name $PROJEC_NAME
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
|
|
1016
1048
|
#### Create a (virtual) folder
|
|
1017
1049
|
|
|
1018
1050
|
New folders can be created within the `Data` dataset and its subfolders using the following command
|
|
@@ -1032,30 +1064,21 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
1032
1064
|
--workspace-id $WORKSPACE_ID \
|
|
1033
1065
|
--project-name $PROJEC_NAME
|
|
1034
1066
|
```
|
|
1067
|
+
#### Removing files and folders
|
|
1035
1068
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
Files and folders can be copied **from** anywhere in the project **to** `Data` or any of its subfolders programmatically (i.e `Data`, `Data/folder/file.txt`).
|
|
1039
|
-
|
|
1040
|
-
1. The copy can happen **within the same project** running the following command:
|
|
1041
|
-
```
|
|
1042
|
-
cloudos datasets cp <souce_path> <destination_path> --profile <profile name>
|
|
1043
|
-
```
|
|
1044
|
-
where the source project as well as the destination one is the one defined in the profile.
|
|
1069
|
+
Files and folders can be removed from file explorer (in the `Data` datasets and its subfolders) using the following command
|
|
1045
1070
|
|
|
1046
|
-
2. The move can also happen **across different projects** within the same workspace by running the following command
|
|
1047
1071
|
```
|
|
1048
|
-
cloudos datasets
|
|
1072
|
+
cloudos datasets rm <path>
|
|
1049
1073
|
```
|
|
1050
|
-
|
|
1074
|
+
where `path` is the full path to the file/folder to be removed.
|
|
1051
1075
|
|
|
1052
|
-
|
|
1076
|
+
Please, be aware that removing files and folders will only remove them from the file explorer and not from the corresponding cloud storage.
|
|
1053
1077
|
|
|
1054
|
-
|
|
1055
|
-
cloudos datasets cp AnalysesResults/my_analysis/results/my_plot.png Data/plots
|
|
1056
|
-
```
|
|
1078
|
+
Please, keep in mind that you are only allowed to remove files or folders in `Data` or its subfolders.
|
|
1057
1079
|
|
|
1058
1080
|
Please, note that in the above example a preconfigured profile has been used. If no profile is provided and there is no default profile, the user will need to also provide the following flags
|
|
1081
|
+
|
|
1059
1082
|
```bash
|
|
1060
1083
|
--cloudos-url $CLOUDOS \
|
|
1061
1084
|
--apikey $MY_API_KEY \
|
|
@@ -978,6 +978,38 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
978
978
|
--workspace-id $WORKSPACE_ID \
|
|
979
979
|
--project-name $PROJEC_NAME
|
|
980
980
|
```
|
|
981
|
+
|
|
982
|
+
#### Copying files and folders
|
|
983
|
+
|
|
984
|
+
Files and folders can be copied **from** anywhere in the project **to** `Data` or any of its subfolders programmatically (i.e `Data`, `Data/folder/file.txt`).
|
|
985
|
+
|
|
986
|
+
1. The copy can happen **within the same project** running the following command:
|
|
987
|
+
```
|
|
988
|
+
cloudos datasets cp <souce_path> <destination_path> --profile <profile name>
|
|
989
|
+
```
|
|
990
|
+
where the source project as well as the destination one is the one defined in the profile.
|
|
991
|
+
|
|
992
|
+
2. The move can also happen **across different projects** within the same workspace by running the following command
|
|
993
|
+
```
|
|
994
|
+
cloudos datasets cp <source_path> <destiantion_path> --profile <profile_name> --destination-project-name <project_name>
|
|
995
|
+
```
|
|
996
|
+
In this case, only the source project is the one specified in the profile.
|
|
997
|
+
|
|
998
|
+
Any of the `source_path` must be a full path; any `destination_path` must be a path starting with `Data` and finishing with the folder where to move the file/folder. An example of such command is:
|
|
999
|
+
|
|
1000
|
+
```
|
|
1001
|
+
cloudos datasets cp AnalysesResults/my_analysis/results/my_plot.png Data/plots
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
Please, note that in the above example a preconfigured profile has been used. If no profile is provided and there is no default profile, the user will need to also provide the following flags
|
|
1005
|
+
```bash
|
|
1006
|
+
--cloudos-url $CLOUDOS \
|
|
1007
|
+
--apikey $MY_API_KEY \
|
|
1008
|
+
--workspace-id $WORKSPACE_ID \
|
|
1009
|
+
--project-name $PROJEC_NAME
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
|
|
981
1013
|
#### Create a (virtual) folder
|
|
982
1014
|
|
|
983
1015
|
New folders can be created within the `Data` dataset and its subfolders using the following command
|
|
@@ -997,30 +1029,21 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
997
1029
|
--workspace-id $WORKSPACE_ID \
|
|
998
1030
|
--project-name $PROJEC_NAME
|
|
999
1031
|
```
|
|
1032
|
+
#### Removing files and folders
|
|
1000
1033
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
Files and folders can be copied **from** anywhere in the project **to** `Data` or any of its subfolders programmatically (i.e `Data`, `Data/folder/file.txt`).
|
|
1004
|
-
|
|
1005
|
-
1. The copy can happen **within the same project** running the following command:
|
|
1006
|
-
```
|
|
1007
|
-
cloudos datasets cp <souce_path> <destination_path> --profile <profile name>
|
|
1008
|
-
```
|
|
1009
|
-
where the source project as well as the destination one is the one defined in the profile.
|
|
1034
|
+
Files and folders can be removed from file explorer (in the `Data` datasets and its subfolders) using the following command
|
|
1010
1035
|
|
|
1011
|
-
2. The move can also happen **across different projects** within the same workspace by running the following command
|
|
1012
1036
|
```
|
|
1013
|
-
cloudos datasets
|
|
1037
|
+
cloudos datasets rm <path>
|
|
1014
1038
|
```
|
|
1015
|
-
|
|
1039
|
+
where `path` is the full path to the file/folder to be removed.
|
|
1016
1040
|
|
|
1017
|
-
|
|
1041
|
+
Please, be aware that removing files and folders will only remove them from the file explorer and not from the corresponding cloud storage.
|
|
1018
1042
|
|
|
1019
|
-
|
|
1020
|
-
cloudos datasets cp AnalysesResults/my_analysis/results/my_plot.png Data/plots
|
|
1021
|
-
```
|
|
1043
|
+
Please, keep in mind that you are only allowed to remove files or folders in `Data` or its subfolders.
|
|
1022
1044
|
|
|
1023
1045
|
Please, note that in the above example a preconfigured profile has been used. If no profile is provided and there is no default profile, the user will need to also provide the following flags
|
|
1046
|
+
|
|
1024
1047
|
```bash
|
|
1025
1048
|
--cloudos-url $CLOUDOS \
|
|
1026
1049
|
--apikey $MY_API_KEY \
|
|
@@ -90,7 +90,8 @@ def run_cloudos_cli(ctx):
|
|
|
90
90
|
'mv': shared_config,
|
|
91
91
|
'rename': shared_config,
|
|
92
92
|
'cp': shared_config,
|
|
93
|
-
'mkdir': shared_config
|
|
93
|
+
'mkdir': shared_config,
|
|
94
|
+
'rm': shared_config
|
|
94
95
|
}
|
|
95
96
|
})
|
|
96
97
|
else:
|
|
@@ -139,7 +140,8 @@ def run_cloudos_cli(ctx):
|
|
|
139
140
|
'mv': shared_config,
|
|
140
141
|
'rename': shared_config,
|
|
141
142
|
'cp': shared_config,
|
|
142
|
-
'mkdir': shared_config
|
|
143
|
+
'mkdir': shared_config,
|
|
144
|
+
'rm': shared_config
|
|
143
145
|
}
|
|
144
146
|
})
|
|
145
147
|
|
|
@@ -3044,7 +3046,7 @@ def copy_item_cli(ctx, source_path, destination_path, apikey, cloudos_url,
|
|
|
3044
3046
|
sys.exit(1)
|
|
3045
3047
|
# Find the source item
|
|
3046
3048
|
source_item = None
|
|
3047
|
-
for item in source_content.get('files'
|
|
3049
|
+
for item in source_content.get('files', []) + source_content.get('folders', []):
|
|
3048
3050
|
if item.get("name") == source_name:
|
|
3049
3051
|
source_item = item
|
|
3050
3052
|
break
|
|
@@ -3206,5 +3208,104 @@ def mkdir_item(ctx, new_folder_path, apikey, cloudos_url,
|
|
|
3206
3208
|
sys.exit(1)
|
|
3207
3209
|
|
|
3208
3210
|
|
|
3211
|
+
@datasets.command(name="rm")
|
|
3212
|
+
@click.argument("target_path", required=True)
|
|
3213
|
+
@click.option('-k', '--apikey', required=True, help='Your CloudOS API key.')
|
|
3214
|
+
@click.option('-c', '--cloudos-url', default=CLOUDOS_URL, required=True, help='The CloudOS URL.')
|
|
3215
|
+
@click.option('--workspace-id', required=True, help='The CloudOS workspace ID.')
|
|
3216
|
+
@click.option('--project-name', required=True, help='The project name.')
|
|
3217
|
+
@click.option('--disable-ssl-verification', is_flag=True, help='Disable SSL certificate verification.')
|
|
3218
|
+
@click.option('--ssl-cert', help='Path to your SSL certificate file.')
|
|
3219
|
+
@click.option('--profile', default=None, help='Profile to use from the config file.')
|
|
3220
|
+
@click.pass_context
|
|
3221
|
+
def rm_item(ctx, target_path, apikey, cloudos_url,
|
|
3222
|
+
workspace_id, project_name,
|
|
3223
|
+
disable_ssl_verification, ssl_cert, profile):
|
|
3224
|
+
"""
|
|
3225
|
+
Delete a file or folder in a CloudOS project.
|
|
3226
|
+
|
|
3227
|
+
TARGET_PATH [path]: the full path to the file or folder to delete. Must start with 'Data'. \n
|
|
3228
|
+
E.g.: 'Data/folderA/file.txt' or 'Data/my_analysis/results/folderB'
|
|
3229
|
+
"""
|
|
3230
|
+
if not target_path.strip("/").startswith("Data/"):
|
|
3231
|
+
click.echo("[ERROR] TARGET_PATH must start with 'Data/', pointing to a file or folder.", err=True)
|
|
3232
|
+
sys.exit(1)
|
|
3233
|
+
click.echo("Loading configuration profile...")
|
|
3234
|
+
config_manager = ConfigurationProfile()
|
|
3235
|
+
required_dict = {
|
|
3236
|
+
'apikey': True,
|
|
3237
|
+
'workspace_id': True,
|
|
3238
|
+
'workflow_name': False,
|
|
3239
|
+
'project_name': True
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
apikey, cloudos_url, workspace_id, workflow_name, repository_platform, execution_platform, project_name = (
|
|
3243
|
+
config_manager.load_profile_and_validate_data(
|
|
3244
|
+
ctx,
|
|
3245
|
+
INIT_PROFILE,
|
|
3246
|
+
CLOUDOS_URL,
|
|
3247
|
+
profile=profile,
|
|
3248
|
+
required_dict=required_dict,
|
|
3249
|
+
apikey=apikey,
|
|
3250
|
+
cloudos_url=cloudos_url,
|
|
3251
|
+
workspace_id=workspace_id,
|
|
3252
|
+
workflow_name=None,
|
|
3253
|
+
repository_platform=None,
|
|
3254
|
+
execution_platform=None,
|
|
3255
|
+
project_name=project_name
|
|
3256
|
+
)
|
|
3257
|
+
)
|
|
3258
|
+
|
|
3259
|
+
verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
|
|
3260
|
+
|
|
3261
|
+
client = Datasets(
|
|
3262
|
+
cloudos_url=cloudos_url,
|
|
3263
|
+
apikey=apikey,
|
|
3264
|
+
workspace_id=workspace_id,
|
|
3265
|
+
project_name=project_name,
|
|
3266
|
+
verify=verify_ssl,
|
|
3267
|
+
cromwell_token=None
|
|
3268
|
+
)
|
|
3269
|
+
|
|
3270
|
+
parts = target_path.strip("/").split("/")
|
|
3271
|
+
parent_path = "/".join(parts[:-1])
|
|
3272
|
+
item_name = parts[-1]
|
|
3273
|
+
|
|
3274
|
+
try:
|
|
3275
|
+
contents = client.list_folder_content(parent_path)
|
|
3276
|
+
except Exception as e:
|
|
3277
|
+
click.echo(f"[ERROR] Could not list contents at '{parent_path or '[project root]'}': {str(e)}", err=True)
|
|
3278
|
+
sys.exit(1)
|
|
3279
|
+
|
|
3280
|
+
found_item = None
|
|
3281
|
+
for item in contents.get('files', []) + contents.get('folders', []):
|
|
3282
|
+
if item.get("name") == item_name:
|
|
3283
|
+
found_item = item
|
|
3284
|
+
break
|
|
3285
|
+
|
|
3286
|
+
if not found_item:
|
|
3287
|
+
click.echo(f"[ERROR] Item '{item_name}' not found in '{parent_path or '[project root]'}'", err=True)
|
|
3288
|
+
sys.exit(1)
|
|
3289
|
+
|
|
3290
|
+
item_id = found_item["_id"]
|
|
3291
|
+
kind = "Folder" if "folderType" in found_item else "File"
|
|
3292
|
+
|
|
3293
|
+
click.echo(f"Deleting {kind} '{item_name}' from '{parent_path or '[root]'}'...")
|
|
3294
|
+
try:
|
|
3295
|
+
response = client.delete_item(item_id=item_id, kind=kind)
|
|
3296
|
+
if response.ok:
|
|
3297
|
+
click.secho(
|
|
3298
|
+
f"[SUCCESS] {kind} '{item_name}' was deleted from '{parent_path or '[root]'}'.",
|
|
3299
|
+
fg="green", bold=True
|
|
3300
|
+
)
|
|
3301
|
+
click.secho("This item will still be available on your Cloud Provider.", fg="yellow")
|
|
3302
|
+
else:
|
|
3303
|
+
click.echo(f"[ERROR] Deletion failed: {response.status_code} - {response.text}", err=True)
|
|
3304
|
+
sys.exit(1)
|
|
3305
|
+
except Exception as e:
|
|
3306
|
+
click.echo(f"[ERROR] Delete operation failed: {str(e)}", err=True)
|
|
3307
|
+
sys.exit(1)
|
|
3308
|
+
|
|
3309
|
+
|
|
3209
3310
|
if __name__ == "__main__":
|
|
3210
3311
|
run_cloudos_cli()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.36.0'
|
|
@@ -5,7 +5,7 @@ This is the main class for file explorer (datasets).
|
|
|
5
5
|
from dataclasses import dataclass
|
|
6
6
|
from typing import Union
|
|
7
7
|
from cloudos_cli.clos import Cloudos
|
|
8
|
-
from cloudos_cli.utils.requests import retry_requests_get, retry_requests_put, retry_requests_post
|
|
8
|
+
from cloudos_cli.utils.requests import retry_requests_get, retry_requests_put, retry_requests_post, retry_requests_delete
|
|
9
9
|
import json
|
|
10
10
|
|
|
11
11
|
@dataclass
|
|
@@ -237,7 +237,7 @@ class Datasets(Cloudos):
|
|
|
237
237
|
else:
|
|
238
238
|
item["s3Prefix"] = item['path']
|
|
239
239
|
item["s3BucketName"] = s3_bucket_name
|
|
240
|
-
|
|
240
|
+
item["fileType"] = "S3File"
|
|
241
241
|
normalized["files"].append(item)
|
|
242
242
|
|
|
243
243
|
return normalized
|
|
@@ -436,7 +436,7 @@ class Datasets(Cloudos):
|
|
|
436
436
|
elif item.get("fileType") == "S3File":
|
|
437
437
|
payload = {
|
|
438
438
|
"s3BucketName": item["s3BucketName"],
|
|
439
|
-
"s3ObjectKey": item
|
|
439
|
+
"s3ObjectKey": item.get("s3ObjectKey") or item.get("s3Prefix"),
|
|
440
440
|
"name": item["name"],
|
|
441
441
|
"parent": parent,
|
|
442
442
|
"isManagedByLifebit": item.get("isManagedByLifebit", False),
|
|
@@ -487,4 +487,34 @@ class Datasets(Cloudos):
|
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
response = retry_requests_post(url, headers=headers, json=payload, verify=self.verify)
|
|
490
|
+
return response
|
|
491
|
+
|
|
492
|
+
def delete_item(self, item_id: str, kind: str):
|
|
493
|
+
"""
|
|
494
|
+
Delete a file or folder in CloudOS.
|
|
495
|
+
|
|
496
|
+
Parameters
|
|
497
|
+
----------
|
|
498
|
+
item_id : str
|
|
499
|
+
The ID of the file or folder to delete.
|
|
500
|
+
kind : str
|
|
501
|
+
Must be either "File" or "Folder".
|
|
502
|
+
|
|
503
|
+
Returns
|
|
504
|
+
-------
|
|
505
|
+
response : requests.Response
|
|
506
|
+
The response object from the CloudOS API.
|
|
507
|
+
"""
|
|
508
|
+
if kind not in ("File", "Folder"):
|
|
509
|
+
raise ValueError("Invalid kind provided. Must be 'File' or 'Folder'.")
|
|
510
|
+
|
|
511
|
+
endpoint = "files" if kind == "File" else "folders"
|
|
512
|
+
url = f"{self.cloudos_url}/api/v1/{endpoint}/{item_id}?teamId={self.workspace_id}"
|
|
513
|
+
|
|
514
|
+
headers = {
|
|
515
|
+
"accept": "application/json",
|
|
516
|
+
"ApiKey": self.apikey
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
response = retry_requests_delete(url, headers=headers, verify=self.verify)
|
|
490
520
|
return response
|
|
@@ -3,7 +3,7 @@ Utility functions and classes to use across the package.
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from .errors import BadRequestException, TimeOutException, AccountNotLinkedException, JoBNotCompletedException, NotAuthorisedException, NoCloudForWorkspaceException
|
|
6
|
-
from .requests import retry_requests_get, retry_requests_post, retry_requests_put
|
|
6
|
+
from .requests import retry_requests_get, retry_requests_post, retry_requests_put, retry_requests_delete
|
|
7
7
|
from .resources import format_bytes, ssl_selector
|
|
8
8
|
from .cloud import find_cloud
|
|
9
9
|
from .cloud import find_cloud
|
|
@@ -107,3 +107,38 @@ def retry_requests_put(url, total=5, status_forcelist=[429, 500, 502, 503, 504],
|
|
|
107
107
|
# Make a request using the session object
|
|
108
108
|
response = session.put(url, **kwargs)
|
|
109
109
|
return response
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def retry_requests_delete(url, total=5, status_forcelist=[429, 500, 502, 503, 504], **kwargs):
|
|
113
|
+
"""
|
|
114
|
+
Wrap normal requests DELETE with an error retry strategy.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
url : str
|
|
119
|
+
The request URL.
|
|
120
|
+
total : int
|
|
121
|
+
Total number of retry attempts.
|
|
122
|
+
status_forcelist : list of int
|
|
123
|
+
HTTP status codes that should trigger a retry.
|
|
124
|
+
**kwargs :
|
|
125
|
+
Additional keyword arguments passed to `requests.delete`.
|
|
126
|
+
|
|
127
|
+
Returns
|
|
128
|
+
-------
|
|
129
|
+
requests.Response
|
|
130
|
+
The Response object returned by the API server.
|
|
131
|
+
"""
|
|
132
|
+
retry_strategy = Retry(
|
|
133
|
+
total=total,
|
|
134
|
+
status_forcelist=status_forcelist,
|
|
135
|
+
allowed_methods=["DELETE"]
|
|
136
|
+
)
|
|
137
|
+
adapter = HTTPAdapter(max_retries=retry_strategy)
|
|
138
|
+
|
|
139
|
+
session = requests.Session()
|
|
140
|
+
session.mount("http://", adapter)
|
|
141
|
+
session.mount("https://", adapter)
|
|
142
|
+
|
|
143
|
+
response = session.delete(url, **kwargs)
|
|
144
|
+
return response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudos_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.36.0
|
|
4
4
|
Summary: Python package for interacting with CloudOS
|
|
5
5
|
Home-page: https://github.com/lifebit-ai/cloudos-cli
|
|
6
6
|
Author: David Piñeyro
|
|
@@ -1013,6 +1013,38 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
1013
1013
|
--workspace-id $WORKSPACE_ID \
|
|
1014
1014
|
--project-name $PROJEC_NAME
|
|
1015
1015
|
```
|
|
1016
|
+
|
|
1017
|
+
#### Copying files and folders
|
|
1018
|
+
|
|
1019
|
+
Files and folders can be copied **from** anywhere in the project **to** `Data` or any of its subfolders programmatically (i.e `Data`, `Data/folder/file.txt`).
|
|
1020
|
+
|
|
1021
|
+
1. The copy can happen **within the same project** running the following command:
|
|
1022
|
+
```
|
|
1023
|
+
cloudos datasets cp <souce_path> <destination_path> --profile <profile name>
|
|
1024
|
+
```
|
|
1025
|
+
where the source project as well as the destination one is the one defined in the profile.
|
|
1026
|
+
|
|
1027
|
+
2. The move can also happen **across different projects** within the same workspace by running the following command
|
|
1028
|
+
```
|
|
1029
|
+
cloudos datasets cp <source_path> <destiantion_path> --profile <profile_name> --destination-project-name <project_name>
|
|
1030
|
+
```
|
|
1031
|
+
In this case, only the source project is the one specified in the profile.
|
|
1032
|
+
|
|
1033
|
+
Any of the `source_path` must be a full path; any `destination_path` must be a path starting with `Data` and finishing with the folder where to move the file/folder. An example of such command is:
|
|
1034
|
+
|
|
1035
|
+
```
|
|
1036
|
+
cloudos datasets cp AnalysesResults/my_analysis/results/my_plot.png Data/plots
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
Please, note that in the above example a preconfigured profile has been used. If no profile is provided and there is no default profile, the user will need to also provide the following flags
|
|
1040
|
+
```bash
|
|
1041
|
+
--cloudos-url $CLOUDOS \
|
|
1042
|
+
--apikey $MY_API_KEY \
|
|
1043
|
+
--workspace-id $WORKSPACE_ID \
|
|
1044
|
+
--project-name $PROJEC_NAME
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
|
|
1016
1048
|
#### Create a (virtual) folder
|
|
1017
1049
|
|
|
1018
1050
|
New folders can be created within the `Data` dataset and its subfolders using the following command
|
|
@@ -1032,30 +1064,21 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
1032
1064
|
--workspace-id $WORKSPACE_ID \
|
|
1033
1065
|
--project-name $PROJEC_NAME
|
|
1034
1066
|
```
|
|
1067
|
+
#### Removing files and folders
|
|
1035
1068
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
Files and folders can be copied **from** anywhere in the project **to** `Data` or any of its subfolders programmatically (i.e `Data`, `Data/folder/file.txt`).
|
|
1039
|
-
|
|
1040
|
-
1. The copy can happen **within the same project** running the following command:
|
|
1041
|
-
```
|
|
1042
|
-
cloudos datasets cp <souce_path> <destination_path> --profile <profile name>
|
|
1043
|
-
```
|
|
1044
|
-
where the source project as well as the destination one is the one defined in the profile.
|
|
1069
|
+
Files and folders can be removed from file explorer (in the `Data` datasets and its subfolders) using the following command
|
|
1045
1070
|
|
|
1046
|
-
2. The move can also happen **across different projects** within the same workspace by running the following command
|
|
1047
1071
|
```
|
|
1048
|
-
cloudos datasets
|
|
1072
|
+
cloudos datasets rm <path>
|
|
1049
1073
|
```
|
|
1050
|
-
|
|
1074
|
+
where `path` is the full path to the file/folder to be removed.
|
|
1051
1075
|
|
|
1052
|
-
|
|
1076
|
+
Please, be aware that removing files and folders will only remove them from the file explorer and not from the corresponding cloud storage.
|
|
1053
1077
|
|
|
1054
|
-
|
|
1055
|
-
cloudos datasets cp AnalysesResults/my_analysis/results/my_plot.png Data/plots
|
|
1056
|
-
```
|
|
1078
|
+
Please, keep in mind that you are only allowed to remove files or folders in `Data` or its subfolders.
|
|
1057
1079
|
|
|
1058
1080
|
Please, note that in the above example a preconfigured profile has been used. If no profile is provided and there is no default profile, the user will need to also provide the following flags
|
|
1081
|
+
|
|
1059
1082
|
```bash
|
|
1060
1083
|
--cloudos-url $CLOUDOS \
|
|
1061
1084
|
--apikey $MY_API_KEY \
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.35.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|