cloudos-cli 2.31.1__tar.gz → 2.32.1__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.31.1 → cloudos_cli-2.32.1}/PKG-INFO +21 -1
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/README.md +20 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/__main__.py +142 -25
- cloudos_cli-2.32.1/cloudos_cli/_version.py +1 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/datasets/datasets.py +37 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/utils/__init__.py +2 -1
- cloudos_cli-2.32.1/cloudos_cli/utils/details.py +66 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli.egg-info/PKG-INFO +21 -1
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli.egg-info/SOURCES.txt +1 -0
- cloudos_cli-2.31.1/cloudos_cli/_version.py +0 -1
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/LICENSE +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/clos.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/configure/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/configure/configure.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/datasets/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/import_wf/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/import_wf/import_wf.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/jobs/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/jobs/job.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/queue/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/queue/queue.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/utils/cloud.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/utils/errors.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/utils/requests.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli/utils/resources.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli.egg-info/dependency_links.txt +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli.egg-info/entry_points.txt +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli.egg-info/requires.txt +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/cloudos_cli.egg-info/top_level.txt +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/setup.cfg +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/setup.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/tests/__init__.py +0 -0
- {cloudos_cli-2.31.1 → cloudos_cli-2.32.1}/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.32.1
|
|
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
|
|
@@ -902,6 +902,26 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
902
902
|
--project-name $PROJEC_NAME
|
|
903
903
|
```
|
|
904
904
|
|
|
905
|
+
#### Renaming files
|
|
906
|
+
|
|
907
|
+
Files and folders within the `Data` dataset can be renamed using the following command
|
|
908
|
+
|
|
909
|
+
```
|
|
910
|
+
cloudos datasets rename <path> <new_name>
|
|
911
|
+
```
|
|
912
|
+
where `path` is the full path to the file/folder to be renamed and `new_name` is just the name, no path required, as the file will not be moved.
|
|
913
|
+
|
|
914
|
+
Please, be aware that renaming can only happen in files and folders that are present in the `Data` datasets and that were created or uploaded by your user.
|
|
915
|
+
|
|
916
|
+
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
|
|
917
|
+
|
|
918
|
+
```bash
|
|
919
|
+
--cloudos-url $CLOUDOS \
|
|
920
|
+
--apikey $MY_API_KEY \
|
|
921
|
+
--workspace-id $WORKSPACE_ID \
|
|
922
|
+
--project-name $PROJEC_NAME
|
|
923
|
+
```
|
|
924
|
+
|
|
905
925
|
### WDL pipeline support
|
|
906
926
|
|
|
907
927
|
#### Cromwell server managing
|
|
@@ -867,6 +867,26 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
867
867
|
--project-name $PROJEC_NAME
|
|
868
868
|
```
|
|
869
869
|
|
|
870
|
+
#### Renaming files
|
|
871
|
+
|
|
872
|
+
Files and folders within the `Data` dataset can be renamed using the following command
|
|
873
|
+
|
|
874
|
+
```
|
|
875
|
+
cloudos datasets rename <path> <new_name>
|
|
876
|
+
```
|
|
877
|
+
where `path` is the full path to the file/folder to be renamed and `new_name` is just the name, no path required, as the file will not be moved.
|
|
878
|
+
|
|
879
|
+
Please, be aware that renaming can only happen in files and folders that are present in the `Data` datasets and that were created or uploaded by your user.
|
|
880
|
+
|
|
881
|
+
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
|
|
882
|
+
|
|
883
|
+
```bash
|
|
884
|
+
--cloudos-url $CLOUDOS \
|
|
885
|
+
--apikey $MY_API_KEY \
|
|
886
|
+
--workspace-id $WORKSPACE_ID \
|
|
887
|
+
--project-name $PROJEC_NAME
|
|
888
|
+
```
|
|
889
|
+
|
|
870
890
|
### WDL pipeline support
|
|
871
891
|
|
|
872
892
|
#### Cromwell server managing
|
|
@@ -16,6 +16,7 @@ from rich.table import Table
|
|
|
16
16
|
from cloudos_cli.datasets import Datasets
|
|
17
17
|
from cloudos_cli.utils.resources import ssl_selector, format_bytes
|
|
18
18
|
from rich.style import Style
|
|
19
|
+
from cloudos_cli.utils.details import get_path
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
# GLOBAL VARS
|
|
@@ -85,7 +86,8 @@ def run_cloudos_cli(ctx):
|
|
|
85
86
|
},
|
|
86
87
|
'datasets': {
|
|
87
88
|
'ls': shared_config,
|
|
88
|
-
'mv': shared_config
|
|
89
|
+
'mv': shared_config,
|
|
90
|
+
'rename': shared_config
|
|
89
91
|
}
|
|
90
92
|
})
|
|
91
93
|
else:
|
|
@@ -130,7 +132,8 @@ def run_cloudos_cli(ctx):
|
|
|
130
132
|
},
|
|
131
133
|
'datasets': {
|
|
132
134
|
'ls': shared_config,
|
|
133
|
-
'mv': shared_config
|
|
135
|
+
'mv': shared_config,
|
|
136
|
+
'rename': shared_config
|
|
134
137
|
}
|
|
135
138
|
})
|
|
136
139
|
|
|
@@ -942,6 +945,19 @@ def job_details(ctx,
|
|
|
942
945
|
sys.exit(1)
|
|
943
946
|
j_details_h = json.loads(j_details.content)
|
|
944
947
|
|
|
948
|
+
# Determine the execution platform based on jobType
|
|
949
|
+
executors = {
|
|
950
|
+
'nextflowAWS': 'Batch AWS',
|
|
951
|
+
'nextflowAzure': 'Batch Azure',
|
|
952
|
+
'nextflowGcp': 'GCP',
|
|
953
|
+
'nextflowHpc': 'HPC',
|
|
954
|
+
'nextflowKubernetes': 'Kubernetes',
|
|
955
|
+
'dockerAWS': 'Batch AWS',
|
|
956
|
+
'cromwellAWS': 'Batch AWS'
|
|
957
|
+
}
|
|
958
|
+
execution_platform = executors.get(j_details_h["jobType"], "None")
|
|
959
|
+
storage_provider = "s3://" if execution_platform == "Batch AWS" else "az://"
|
|
960
|
+
|
|
945
961
|
# Check if the job details contain parameters
|
|
946
962
|
if j_details_h["parameters"] != []:
|
|
947
963
|
param_kind_map = {
|
|
@@ -949,18 +965,15 @@ def job_details(ctx,
|
|
|
949
965
|
'arrayFileColumn': 'columnName',
|
|
950
966
|
'globPattern': 'globPattern',
|
|
951
967
|
'lustreFileSystem': 'fileSystem',
|
|
968
|
+
'dataItem': 'dataItem'
|
|
952
969
|
}
|
|
953
970
|
# there are different types of parameters, arrayFileColumn, globPattern, lustreFileSystem
|
|
954
971
|
# get first the type of parameter, then the value based on the parameter kind
|
|
955
972
|
concats = []
|
|
956
973
|
for param in j_details_h["parameters"]:
|
|
957
|
-
|
|
958
|
-
# For dataItem, we need to use specific nested keys
|
|
959
|
-
concats.append(f"{param['prefix']}{param['name']}={param['dataItem']['item']['name']}")
|
|
960
|
-
else:
|
|
961
|
-
# For other parameter kinds, we use the appropriate key from param_kind_map
|
|
962
|
-
concats.append(f"{param['prefix']}{param['name']}={param[param_kind_map[param['parameterKind']]]}")
|
|
974
|
+
concats.append(f"{param['prefix']}{param['name']}={get_path(param, param_kind_map, execution_platform, storage_provider, 'asis')}")
|
|
963
975
|
concat_string = '\n'.join(concats)
|
|
976
|
+
|
|
964
977
|
# If the user requested to save the parameters in a config file
|
|
965
978
|
if parameters:
|
|
966
979
|
# Create a config file with the parameters
|
|
@@ -968,7 +981,7 @@ def job_details(ctx,
|
|
|
968
981
|
with open(config_filename, 'w') as config_file:
|
|
969
982
|
config_file.write("params {\n")
|
|
970
983
|
for param in j_details_h["parameters"]:
|
|
971
|
-
config_file.write(f"\t{param['name']} = {param
|
|
984
|
+
config_file.write(f"\t{param['name']} = {get_path(param, param_kind_map, execution_platform, storage_provider)}\n")
|
|
972
985
|
config_file.write("}\n")
|
|
973
986
|
print(f"\tJob parameters have been saved to '{config_filename}'")
|
|
974
987
|
else:
|
|
@@ -976,18 +989,6 @@ def job_details(ctx,
|
|
|
976
989
|
if parameters:
|
|
977
990
|
print("\tNo parameters found in the job details, no config file will be created.")
|
|
978
991
|
|
|
979
|
-
# Determine the execution platform based on jobType
|
|
980
|
-
executors = {
|
|
981
|
-
'nextflowAWS': 'Batch AWS',
|
|
982
|
-
'nextflowAzure': 'Batch Azure',
|
|
983
|
-
'nextflowGcp': 'GCP',
|
|
984
|
-
'nextflowHpc': 'HPC',
|
|
985
|
-
'nextflowKubernetes': 'Kubernetes',
|
|
986
|
-
'dockerAWS': 'Batch AWS',
|
|
987
|
-
'cromwellAWS': 'Batch AWS'
|
|
988
|
-
}
|
|
989
|
-
execution_platform = executors.get(j_details_h["jobType"], "None")
|
|
990
|
-
|
|
991
992
|
# revision
|
|
992
993
|
if j_details_h["jobType"] == "dockerAWS":
|
|
993
994
|
revision = j_details_h["revision"]["digest"]
|
|
@@ -1010,7 +1011,11 @@ def job_details(ctx,
|
|
|
1010
1011
|
table.add_row("Nextflow Version", str(j_details_h.get("nextflowVersion", "None")))
|
|
1011
1012
|
table.add_row("Execution Platform", execution_platform)
|
|
1012
1013
|
table.add_row("Profile", str(j_details_h.get("profile", "None")))
|
|
1013
|
-
|
|
1014
|
+
# when the job is just running this value might not be present
|
|
1015
|
+
master_instance = j_details_h.get("masterInstance", {})
|
|
1016
|
+
used_instance = master_instance.get("usedInstance", {})
|
|
1017
|
+
instance_type = used_instance.get("type", "N/A")
|
|
1018
|
+
table.add_row("Master Instance", str(instance_type))
|
|
1014
1019
|
if j_details_h["jobType"] == "nextflowAzure":
|
|
1015
1020
|
try:
|
|
1016
1021
|
table.add_row("Worker Node", str(j_details_h["azureBatch"]["vmType"]))
|
|
@@ -1037,7 +1042,6 @@ def job_details(ctx,
|
|
|
1037
1042
|
"Nextflow Version": str(j_details_h.get("nextflowVersion", "None")),
|
|
1038
1043
|
"Execution Platform": execution_platform,
|
|
1039
1044
|
"Profile": str(j_details_h.get("profile", "None")),
|
|
1040
|
-
"Master Instance": str(j_details_h["masterInstance"]["usedInstance"]["type"]),
|
|
1041
1045
|
"Storage": str(j_details_h["storageSizeInGb"]) + " GB",
|
|
1042
1046
|
"Accelerated File Staging": str(j_details_h.get("usesFusionFileSystem", "None")),
|
|
1043
1047
|
"Task Resources": f"{str(j_details_h['resourceRequirements']['cpu'])} CPUs, " +
|
|
@@ -1045,6 +1049,12 @@ def job_details(ctx,
|
|
|
1045
1049
|
|
|
1046
1050
|
}
|
|
1047
1051
|
|
|
1052
|
+
# when the job is just running this value might not be present
|
|
1053
|
+
master_instance = j_details_h.get("masterInstance", {})
|
|
1054
|
+
used_instance = master_instance.get("usedInstance", {})
|
|
1055
|
+
instance_type = used_instance.get("type", "N/A")
|
|
1056
|
+
job_details_json["Master Instance"] = str(instance_type)
|
|
1057
|
+
|
|
1048
1058
|
# Conditionally add the "Command" key if the jobType is "dockerAWS"
|
|
1049
1059
|
if j_details_h["jobType"] == "dockerAWS":
|
|
1050
1060
|
job_details_json["Command"] = str(j_details_h["command"])
|
|
@@ -2351,8 +2361,7 @@ def move_files(ctx, source_path, destination_path, apikey, cloudos_url, workspac
|
|
|
2351
2361
|
"""
|
|
2352
2362
|
|
|
2353
2363
|
profile = profile or ctx.default_map['datasets']['move'].get('profile')
|
|
2354
|
-
|
|
2355
|
-
|
|
2364
|
+
|
|
2356
2365
|
# Validate destination constraint
|
|
2357
2366
|
if not destination_path.strip("/").startswith("Data/") and destination_path.strip("/") != "Data":
|
|
2358
2367
|
click.echo("[ERROR] Destination path must begin with 'Data/' or be 'Data'.", err=True)
|
|
@@ -2388,6 +2397,8 @@ def move_files(ctx, source_path, destination_path, apikey, cloudos_url, workspac
|
|
|
2388
2397
|
)
|
|
2389
2398
|
|
|
2390
2399
|
verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
|
|
2400
|
+
|
|
2401
|
+
destination_project_name = destination_project_name or project_name
|
|
2391
2402
|
# Initialize Datasets clients
|
|
2392
2403
|
source_client = Datasets(
|
|
2393
2404
|
cloudos_url=cloudos_url,
|
|
@@ -2479,5 +2490,111 @@ def move_files(ctx, source_path, destination_path, apikey, cloudos_url, workspac
|
|
|
2479
2490
|
sys.exit(1)
|
|
2480
2491
|
|
|
2481
2492
|
|
|
2493
|
+
@datasets.command(name="rename")
|
|
2494
|
+
@click.argument("source_path", required=True)
|
|
2495
|
+
@click.argument("new_name", required=True)
|
|
2496
|
+
@click.option('-k', '--apikey', required=True, help='Your CloudOS API key.')
|
|
2497
|
+
@click.option('-c', '--cloudos-url', default=CLOUDOS_URL, required=True, help='The CloudOS URL.')
|
|
2498
|
+
@click.option('--workspace-id', required=True, help='The CloudOS workspace ID.')
|
|
2499
|
+
@click.option('--project-name', required=True, help='The project name.')
|
|
2500
|
+
@click.option('--disable-ssl-verification', is_flag=True, help='Disable SSL certificate verification.')
|
|
2501
|
+
@click.option('--ssl-cert', help='Path to your SSL certificate file.')
|
|
2502
|
+
@click.option('--profile', default=None, help='Profile to use from the config file.')
|
|
2503
|
+
@click.pass_context
|
|
2504
|
+
def renaming_item(ctx, source_path, new_name, apikey, cloudos_url,
|
|
2505
|
+
workspace_id, project_name,
|
|
2506
|
+
disable_ssl_verification, ssl_cert, profile):
|
|
2507
|
+
"""
|
|
2508
|
+
Rename a file or folder in a CloudOS project.
|
|
2509
|
+
|
|
2510
|
+
SOURCE_PATH [path]: the full path to the file or folder to rename. It must be a 'Data' folder path.
|
|
2511
|
+
E.g.: 'Data/folderA/old_name.txt'\n
|
|
2512
|
+
NEW_NAME [name]: the new name to assign to the file or folder. E.g.: 'new_name.txt'
|
|
2513
|
+
"""
|
|
2514
|
+
if not source_path.strip("/").startswith("Data/"):
|
|
2515
|
+
click.echo("[ERROR] SOURCE_PATH must start with 'Data/', pointing to a file/folder in that dataset.", err=True)
|
|
2516
|
+
sys.exit(1)
|
|
2517
|
+
click.echo("Loading configuration profile...")
|
|
2518
|
+
config_manager = ConfigurationProfile()
|
|
2519
|
+
required_dict = {
|
|
2520
|
+
'apikey': True,
|
|
2521
|
+
'workspace_id': True,
|
|
2522
|
+
'workflow_name': False,
|
|
2523
|
+
'project_name': True
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
apikey, cloudos_url, workspace_id, workflow_name, repository_platform, execution_platform, project_name = (
|
|
2527
|
+
config_manager.load_profile_and_validate_data(
|
|
2528
|
+
ctx,
|
|
2529
|
+
INIT_PROFILE,
|
|
2530
|
+
CLOUDOS_URL,
|
|
2531
|
+
profile=profile,
|
|
2532
|
+
required_dict=required_dict,
|
|
2533
|
+
apikey=apikey,
|
|
2534
|
+
cloudos_url=cloudos_url,
|
|
2535
|
+
workspace_id=workspace_id,
|
|
2536
|
+
workflow_name=None,
|
|
2537
|
+
repository_platform=None,
|
|
2538
|
+
execution_platform=None,
|
|
2539
|
+
project_name=project_name
|
|
2540
|
+
)
|
|
2541
|
+
)
|
|
2542
|
+
|
|
2543
|
+
verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
|
|
2544
|
+
# Initialize Datasets clients
|
|
2545
|
+
client = Datasets(
|
|
2546
|
+
cloudos_url=cloudos_url,
|
|
2547
|
+
apikey=apikey,
|
|
2548
|
+
workspace_id=workspace_id,
|
|
2549
|
+
project_name=project_name,
|
|
2550
|
+
verify=verify_ssl,
|
|
2551
|
+
cromwell_token=None
|
|
2552
|
+
)
|
|
2553
|
+
|
|
2554
|
+
parts = source_path.strip("/").split("/")
|
|
2555
|
+
|
|
2556
|
+
parent_path = "/".join(parts[:-1])
|
|
2557
|
+
target_name = parts[-1]
|
|
2558
|
+
|
|
2559
|
+
try:
|
|
2560
|
+
contents = client.list_folder_content(parent_path)
|
|
2561
|
+
except Exception as e:
|
|
2562
|
+
click.echo(f"[ERROR] Could not list contents at '{parent_path or '[project root]'}': {str(e)}", err=True)
|
|
2563
|
+
sys.exit(1)
|
|
2564
|
+
|
|
2565
|
+
# Search for file/folder
|
|
2566
|
+
found_item = None
|
|
2567
|
+
for category in ["files", "folders"]:
|
|
2568
|
+
for item in contents.get(category, []):
|
|
2569
|
+
if item.get("name") == target_name:
|
|
2570
|
+
found_item = item
|
|
2571
|
+
break
|
|
2572
|
+
if found_item:
|
|
2573
|
+
break
|
|
2574
|
+
|
|
2575
|
+
if not found_item:
|
|
2576
|
+
click.echo(f"[ERROR] Item '{target_name}' not found in '{parent_path or '[project root]'}'", err=True)
|
|
2577
|
+
sys.exit(1)
|
|
2578
|
+
|
|
2579
|
+
item_id = found_item["_id"]
|
|
2580
|
+
kind = "Folder" if "folderType" in found_item else "File"
|
|
2581
|
+
|
|
2582
|
+
click.echo(f"Renaming {kind} '{target_name}' to '{new_name}'...")
|
|
2583
|
+
try:
|
|
2584
|
+
response = client.rename_item(item_id=item_id, new_name=new_name, kind=kind)
|
|
2585
|
+
if response.ok:
|
|
2586
|
+
click.secho(
|
|
2587
|
+
f"[SUCCESS] {kind} '{target_name}' renamed to '{new_name}' in folder '{parent_path}'.",
|
|
2588
|
+
fg="green",
|
|
2589
|
+
bold=True
|
|
2590
|
+
)
|
|
2591
|
+
else:
|
|
2592
|
+
click.echo(f"[ERROR] Rename failed: {response.status_code} - {response.text}", err=True)
|
|
2593
|
+
sys.exit(1)
|
|
2594
|
+
except Exception as e:
|
|
2595
|
+
click.echo(f"[ERROR] Rename operation failed: {str(e)}", err=True)
|
|
2596
|
+
sys.exit(1)
|
|
2597
|
+
|
|
2598
|
+
|
|
2482
2599
|
if __name__ == "__main__":
|
|
2483
2600
|
run_cloudos_cli()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.32.1'
|
|
@@ -365,5 +365,42 @@ class Datasets(Cloudos):
|
|
|
365
365
|
"item": target_id
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
+
response = retry_requests_put(url, headers=headers, data=json.dumps(payload), verify=self.verify)
|
|
369
|
+
return response
|
|
370
|
+
|
|
371
|
+
def rename_item(self, item_id: str, new_name: str, kind: str):
|
|
372
|
+
"""
|
|
373
|
+
Rename a file or folder in CloudOS.
|
|
374
|
+
|
|
375
|
+
Parameters
|
|
376
|
+
----------
|
|
377
|
+
item_id : str
|
|
378
|
+
The ID of the file or folder to rename.
|
|
379
|
+
new_name : str
|
|
380
|
+
The new name to assign to the item.
|
|
381
|
+
kind : str
|
|
382
|
+
Either "File" or "Folder"
|
|
383
|
+
|
|
384
|
+
Returns
|
|
385
|
+
-------
|
|
386
|
+
response : requests.Response
|
|
387
|
+
The response object from the CloudOS API.
|
|
388
|
+
"""
|
|
389
|
+
if kind not in ("File", "Folder"):
|
|
390
|
+
raise ValueError("Invalid kind provided. Must be 'File' or 'Folder'.")
|
|
391
|
+
|
|
392
|
+
endpoint = "files" if kind == "File" else "folders"
|
|
393
|
+
url = f"{self.cloudos_url}/api/v1/{endpoint}/{item_id}?teamId={self.workspace_id}"
|
|
394
|
+
|
|
395
|
+
headers = {
|
|
396
|
+
"accept": "application/json",
|
|
397
|
+
"content-type": "application/json",
|
|
398
|
+
"ApiKey": self.apikey
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
payload = {
|
|
402
|
+
"name": new_name
|
|
403
|
+
}
|
|
404
|
+
|
|
368
405
|
response = retry_requests_put(url, headers=headers, data=json.dumps(payload), verify=self.verify)
|
|
369
406
|
return response
|
|
@@ -7,5 +7,6 @@ from .requests import retry_requests_get, retry_requests_post, retry_requests_pu
|
|
|
7
7
|
from .resources import format_bytes, ssl_selector
|
|
8
8
|
from .cloud import find_cloud
|
|
9
9
|
from .cloud import find_cloud
|
|
10
|
+
from .details import get_path
|
|
10
11
|
|
|
11
|
-
__all__ = ['errors', 'requests', 'resources', 'cloud']
|
|
12
|
+
__all__ = ['errors', 'requests', 'resources', 'cloud', 'details']
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
def get_path(param, param_kind_map, execution_platform, storage_provider, mode="parameters"):
|
|
2
|
+
"""
|
|
3
|
+
Constructs a storage path based on the parameter kind and execution platform.
|
|
4
|
+
|
|
5
|
+
Parameters
|
|
6
|
+
----------
|
|
7
|
+
param : dict
|
|
8
|
+
A dictionary containing parameter details. Expected keys include:
|
|
9
|
+
- 'parameterKind': Specifies the kind of parameter (e.g., 'dataItem', 'globPattern').
|
|
10
|
+
- For 'dataItem': Contains nested keys such as 'item', which includes:
|
|
11
|
+
- 's3BucketName', 's3ObjectKey', 's3Prefix' (for AWS Batch).
|
|
12
|
+
- 'blobStorageAccountName', 'blobContainerName', 'blobName' (for other platforms).
|
|
13
|
+
- For 'globPattern': Contains nested keys such as 'folder', which includes:
|
|
14
|
+
- 's3BucketName', 's3Prefix' (for AWS Batch).
|
|
15
|
+
- 'blobStorageAccountName', 'blobContainerName', 'blobPrefix' (for other platforms).
|
|
16
|
+
param_kind_map : dict
|
|
17
|
+
A mapping of parameter kinds to their corresponding keys in the `param` dictionary.
|
|
18
|
+
execution_platform : str
|
|
19
|
+
The platform on which the execution is taking place.
|
|
20
|
+
Expected values include "Batch AWS" or other non-AWS platforms.
|
|
21
|
+
storage_provider : str
|
|
22
|
+
Either s3:// or az://
|
|
23
|
+
mode : str
|
|
24
|
+
For "parameters" is creating the '*.config' file and it adds the complete path, for "asis"
|
|
25
|
+
leaves the constructed path as generated from the API
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
str: A constructed storage path based on the parameter kind and execution platform.
|
|
30
|
+
- For 'dataItem' on AWS Batch: "s3BucketName/s3ObjectKey" or "s3BucketName/s3Prefix".
|
|
31
|
+
- For 'dataItem' on other platforms: "blobStorageAccountName/blobContainerName/blobName".
|
|
32
|
+
- For 'globPattern' on AWS Batch: "s3BucketName/s3Prefix/globPattern".
|
|
33
|
+
- For 'globPattern' on other platforms: "blobStorageAccountName/blobContainerName/blobPrefix/globPattern".
|
|
34
|
+
"""
|
|
35
|
+
value = param[param_kind_map[param['parameterKind']]]
|
|
36
|
+
if param['parameterKind'] == 'dataItem':
|
|
37
|
+
if execution_platform == "Batch AWS":
|
|
38
|
+
s3_object_key = value['item'].get('s3ObjectKey', None) if value['item'].get('s3Prefix', None) is None else value['item'].get('s3Prefix', None)
|
|
39
|
+
if mode == "parameters":
|
|
40
|
+
value = storage_provider + value['item']['s3BucketName'] + '/' + s3_object_key
|
|
41
|
+
else:
|
|
42
|
+
value = value['item']['s3BucketName'] + '/' + s3_object_key
|
|
43
|
+
else:
|
|
44
|
+
account_name = value['item']['blobStorageAccountName'] + ".blob.core.windows.net"
|
|
45
|
+
container_name = value['item']['blobContainerName']
|
|
46
|
+
blob_name = value['item']['blobName']
|
|
47
|
+
if mode == "parameters":
|
|
48
|
+
value = storage_provider + account_name + '/' + container_name + '/' + blob_name
|
|
49
|
+
else:
|
|
50
|
+
value = value['item']['blobStorageAccountName'] + '/' + container_name + '/' + blob_name
|
|
51
|
+
elif param['parameterKind'] == 'globPattern':
|
|
52
|
+
if execution_platform == "Batch AWS":
|
|
53
|
+
if mode == "parameters":
|
|
54
|
+
value = storage_provider + param['folder']['s3BucketName'] + '/' + param['folder']['s3Prefix'] + '/' + param['globPattern']
|
|
55
|
+
else:
|
|
56
|
+
value = param['folder']['s3BucketName'] + '/' + param['folder']['s3Prefix'] + '/' + param['globPattern']
|
|
57
|
+
else:
|
|
58
|
+
account_name = param['folder']['blobStorageAccountName'] + ".blob.core.windows.net"
|
|
59
|
+
container_name = param['folder']['blobContainerName']
|
|
60
|
+
blob_name = param['folder']['blobPrefix']
|
|
61
|
+
if mode == "parameters":
|
|
62
|
+
value = storage_provider + account_name + '/' + container_name + '/' + blob_name + '/' + param['globPattern']
|
|
63
|
+
else:
|
|
64
|
+
value = param['folder']['blobStorageAccountName'] + '/' + container_name + '/' + blob_name + '/' + param['globPattern']
|
|
65
|
+
|
|
66
|
+
return value
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudos_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.32.1
|
|
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
|
|
@@ -902,6 +902,26 @@ Please, note that in the above example a preconfigured profile has been used. If
|
|
|
902
902
|
--project-name $PROJEC_NAME
|
|
903
903
|
```
|
|
904
904
|
|
|
905
|
+
#### Renaming files
|
|
906
|
+
|
|
907
|
+
Files and folders within the `Data` dataset can be renamed using the following command
|
|
908
|
+
|
|
909
|
+
```
|
|
910
|
+
cloudos datasets rename <path> <new_name>
|
|
911
|
+
```
|
|
912
|
+
where `path` is the full path to the file/folder to be renamed and `new_name` is just the name, no path required, as the file will not be moved.
|
|
913
|
+
|
|
914
|
+
Please, be aware that renaming can only happen in files and folders that are present in the `Data` datasets and that were created or uploaded by your user.
|
|
915
|
+
|
|
916
|
+
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
|
|
917
|
+
|
|
918
|
+
```bash
|
|
919
|
+
--cloudos-url $CLOUDOS \
|
|
920
|
+
--apikey $MY_API_KEY \
|
|
921
|
+
--workspace-id $WORKSPACE_ID \
|
|
922
|
+
--project-name $PROJEC_NAME
|
|
923
|
+
```
|
|
924
|
+
|
|
905
925
|
### WDL pipeline support
|
|
906
926
|
|
|
907
927
|
#### Cromwell server managing
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.31.1'
|
|
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
|