cloudos-cli 2.31.1__tar.gz → 2.32.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.
Files changed (33) hide show
  1. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/PKG-INFO +21 -1
  2. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/README.md +20 -0
  3. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/__main__.py +113 -4
  4. cloudos_cli-2.32.0/cloudos_cli/_version.py +1 -0
  5. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/datasets/datasets.py +37 -0
  6. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli.egg-info/PKG-INFO +21 -1
  7. cloudos_cli-2.31.1/cloudos_cli/_version.py +0 -1
  8. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/LICENSE +0 -0
  9. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/__init__.py +0 -0
  10. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/clos.py +0 -0
  11. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/configure/__init__.py +0 -0
  12. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/configure/configure.py +0 -0
  13. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/datasets/__init__.py +0 -0
  14. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/import_wf/__init__.py +0 -0
  15. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/import_wf/import_wf.py +0 -0
  16. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/jobs/__init__.py +0 -0
  17. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/jobs/job.py +0 -0
  18. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/queue/__init__.py +0 -0
  19. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/queue/queue.py +0 -0
  20. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/utils/__init__.py +0 -0
  21. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/utils/cloud.py +0 -0
  22. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/utils/errors.py +0 -0
  23. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/utils/requests.py +0 -0
  24. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli/utils/resources.py +0 -0
  25. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli.egg-info/SOURCES.txt +0 -0
  26. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli.egg-info/dependency_links.txt +0 -0
  27. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli.egg-info/entry_points.txt +0 -0
  28. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli.egg-info/requires.txt +0 -0
  29. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/cloudos_cli.egg-info/top_level.txt +0 -0
  30. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/setup.cfg +0 -0
  31. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/setup.py +0 -0
  32. {cloudos_cli-2.31.1 → cloudos_cli-2.32.0}/tests/__init__.py +0 -0
  33. {cloudos_cli-2.31.1 → cloudos_cli-2.32.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.31.1
3
+ Version: 2.32.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
@@ -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
@@ -85,7 +85,8 @@ def run_cloudos_cli(ctx):
85
85
  },
86
86
  'datasets': {
87
87
  'ls': shared_config,
88
- 'mv': shared_config
88
+ 'mv': shared_config,
89
+ 'rename': shared_config
89
90
  }
90
91
  })
91
92
  else:
@@ -130,7 +131,8 @@ def run_cloudos_cli(ctx):
130
131
  },
131
132
  'datasets': {
132
133
  'ls': shared_config,
133
- 'mv': shared_config
134
+ 'mv': shared_config,
135
+ 'rename': shared_config
134
136
  }
135
137
  })
136
138
 
@@ -2351,8 +2353,7 @@ def move_files(ctx, source_path, destination_path, apikey, cloudos_url, workspac
2351
2353
  """
2352
2354
 
2353
2355
  profile = profile or ctx.default_map['datasets']['move'].get('profile')
2354
- destination_project_name = destination_project_name or project_name
2355
-
2356
+
2356
2357
  # Validate destination constraint
2357
2358
  if not destination_path.strip("/").startswith("Data/") and destination_path.strip("/") != "Data":
2358
2359
  click.echo("[ERROR] Destination path must begin with 'Data/' or be 'Data'.", err=True)
@@ -2388,6 +2389,8 @@ def move_files(ctx, source_path, destination_path, apikey, cloudos_url, workspac
2388
2389
  )
2389
2390
 
2390
2391
  verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
2392
+
2393
+ destination_project_name = destination_project_name or project_name
2391
2394
  # Initialize Datasets clients
2392
2395
  source_client = Datasets(
2393
2396
  cloudos_url=cloudos_url,
@@ -2479,5 +2482,111 @@ def move_files(ctx, source_path, destination_path, apikey, cloudos_url, workspac
2479
2482
  sys.exit(1)
2480
2483
 
2481
2484
 
2485
+ @datasets.command(name="rename")
2486
+ @click.argument("source_path", required=True)
2487
+ @click.argument("new_name", required=True)
2488
+ @click.option('-k', '--apikey', required=True, help='Your CloudOS API key.')
2489
+ @click.option('-c', '--cloudos-url', default=CLOUDOS_URL, required=True, help='The CloudOS URL.')
2490
+ @click.option('--workspace-id', required=True, help='The CloudOS workspace ID.')
2491
+ @click.option('--project-name', required=True, help='The project name.')
2492
+ @click.option('--disable-ssl-verification', is_flag=True, help='Disable SSL certificate verification.')
2493
+ @click.option('--ssl-cert', help='Path to your SSL certificate file.')
2494
+ @click.option('--profile', default=None, help='Profile to use from the config file.')
2495
+ @click.pass_context
2496
+ def renaming_item(ctx, source_path, new_name, apikey, cloudos_url,
2497
+ workspace_id, project_name,
2498
+ disable_ssl_verification, ssl_cert, profile):
2499
+ """
2500
+ Rename a file or folder in a CloudOS project.
2501
+
2502
+ SOURCE_PATH [path]: the full path to the file or folder to rename. It must be a 'Data' folder path.
2503
+ E.g.: 'Data/folderA/old_name.txt'\n
2504
+ NEW_NAME [name]: the new name to assign to the file or folder. E.g.: 'new_name.txt'
2505
+ """
2506
+ if not source_path.strip("/").startswith("Data/"):
2507
+ click.echo("[ERROR] SOURCE_PATH must start with 'Data/', pointing to a file/folder in that dataset.", err=True)
2508
+ sys.exit(1)
2509
+ click.echo("Loading configuration profile...")
2510
+ config_manager = ConfigurationProfile()
2511
+ required_dict = {
2512
+ 'apikey': True,
2513
+ 'workspace_id': True,
2514
+ 'workflow_name': False,
2515
+ 'project_name': True
2516
+ }
2517
+
2518
+ apikey, cloudos_url, workspace_id, workflow_name, repository_platform, execution_platform, project_name = (
2519
+ config_manager.load_profile_and_validate_data(
2520
+ ctx,
2521
+ INIT_PROFILE,
2522
+ CLOUDOS_URL,
2523
+ profile=profile,
2524
+ required_dict=required_dict,
2525
+ apikey=apikey,
2526
+ cloudos_url=cloudos_url,
2527
+ workspace_id=workspace_id,
2528
+ workflow_name=None,
2529
+ repository_platform=None,
2530
+ execution_platform=None,
2531
+ project_name=project_name
2532
+ )
2533
+ )
2534
+
2535
+ verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
2536
+ # Initialize Datasets clients
2537
+ client = Datasets(
2538
+ cloudos_url=cloudos_url,
2539
+ apikey=apikey,
2540
+ workspace_id=workspace_id,
2541
+ project_name=project_name,
2542
+ verify=verify_ssl,
2543
+ cromwell_token=None
2544
+ )
2545
+
2546
+ parts = source_path.strip("/").split("/")
2547
+
2548
+ parent_path = "/".join(parts[:-1])
2549
+ target_name = parts[-1]
2550
+
2551
+ try:
2552
+ contents = client.list_folder_content(parent_path)
2553
+ except Exception as e:
2554
+ click.echo(f"[ERROR] Could not list contents at '{parent_path or '[project root]'}': {str(e)}", err=True)
2555
+ sys.exit(1)
2556
+
2557
+ # Search for file/folder
2558
+ found_item = None
2559
+ for category in ["files", "folders"]:
2560
+ for item in contents.get(category, []):
2561
+ if item.get("name") == target_name:
2562
+ found_item = item
2563
+ break
2564
+ if found_item:
2565
+ break
2566
+
2567
+ if not found_item:
2568
+ click.echo(f"[ERROR] Item '{target_name}' not found in '{parent_path or '[project root]'}'", err=True)
2569
+ sys.exit(1)
2570
+
2571
+ item_id = found_item["_id"]
2572
+ kind = "Folder" if "folderType" in found_item else "File"
2573
+
2574
+ click.echo(f"Renaming {kind} '{target_name}' to '{new_name}'...")
2575
+ try:
2576
+ response = client.rename_item(item_id=item_id, new_name=new_name, kind=kind)
2577
+ if response.ok:
2578
+ click.secho(
2579
+ f"[SUCCESS] {kind} '{target_name}' renamed to '{new_name}' in folder '{parent_path}'.",
2580
+ fg="green",
2581
+ bold=True
2582
+ )
2583
+ else:
2584
+ click.echo(f"[ERROR] Rename failed: {response.status_code} - {response.text}", err=True)
2585
+ sys.exit(1)
2586
+ except Exception as e:
2587
+ click.echo(f"[ERROR] Rename operation failed: {str(e)}", err=True)
2588
+ sys.exit(1)
2589
+
2590
+
2482
2591
  if __name__ == "__main__":
2483
2592
  run_cloudos_cli()
@@ -0,0 +1 @@
1
+ __version__ = '2.32.0'
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.31.1
3
+ Version: 2.32.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
@@ -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