Skip to content

Commit c9d842e

Browse files
committed
adding HPC file transfer capability
1 parent 2e4da69 commit c9d842e

File tree

3 files changed

+84
-5
lines changed

3 files changed

+84
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Select the destination location
2+
3+
=== "Destination: Clowder Dataset"
4+
Select from available datasets in Clowder, or create a new dataset to be the destination.
5+
6+
## Select the destination Clowder dataset.
7+
=== "expand(cat .v2_available_clowder_datasets.txt | tr -d '[]')"
8+
```shell
9+
echo "👉 Selected destination dataset: ${choice}"
10+
```
11+
12+
=== "Destination: HPC [default: none]"
13+
SSH to your HPC resource and copy data from any path there to any destination. You can supply a list of files, or a path to a directory.
14+
```shell
15+
python ./CodeFlare-Extractors/codeflare_helpers/select_path_on_hpc.py
16+
echo "👉 Starting copy from Clowder 🐱 to HPC 🏢."
17+
```
18+
19+
# Enter the destination path on HPC. The dataset will be copied to a folder inside this path.
20+
=== "Enter the destination path on HPC (e.g. name@hpc_cluster:/data_path/) [default: ~/]"
21+
details here.
22+
```shell
23+
echo "👉 Selected destination path: ${choice}"
24+
# export HPC_DESTINATION_PATH=${choice}
25+
```
26+
27+
=== "Destination: AWS S3"
28+
Select from available buckets in AWS S3. Transfer the entire bucket, or a list of files. Ensure '$ aws s3 ls' works on your machine.
29+
30+
# Enter the destination S3 bucket name and sub-folder. The dataset will be copied to a folder inside this path.
31+
=== "Enter the destination path on S3 (e.g. s3://my-bucket/data/destination/) [default: s3://my-bucket]"
32+
details here.
33+
```shell
34+
echo "👉 Selected destination path: ${choice}"
35+
# export HPC_DESTINATION_PATH=${choice}
36+
```

codeflare_helpers/launch_clowder.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#!/bin/bash
22

33
# no sudo for mac Docker, yes sudo for linux.
4-
echo "Starting Clowder with extractors"
4+
echo " 👉 Starting Clowder with extractors"
55
if [ $(uname) = "Darwin" ]; then
6-
echo "Platform is MacOS"
6+
# echo "Platform is MacOS"
77
docker-compose -f docker-compose.yml -f docker-compose.extractors.yml up -d
88
echo "🌐 Starting Clowder (http://localhost:8000) in your default browser"
9-
open http://localhost:8000
9+
open --url http://localhost:8000 --background --hide
1010
echo "❓ It may take up to a minute for the containers to start up, please try refreshing the page a few times."
1111

1212
elif [ $(uname -r | grep -c "microsoft") -eq 1 ]; then
13-
echo "Platform is WSL2"
13+
# echo "Platform is WSL2"
1414
sudo docker-compose -f docker-compose.yml -f docker-compose.extractors.yml up -d
1515
echo "🌐 Starting Clowder (http://localhost:8000) in your default browser"
1616
wslview http://localhost:8000
1717
echo "❓ It may take up to a minute for the containers to start up, please try refreshing the page a few times."
1818

1919
elif [ $(uname) = "Linux" ]; then
20-
echo "Platform is Linux"
20+
# echo "Platform is Linux"
2121
sudo docker-compose -f docker-compose.yml -f docker-compose.extractors.yml up -d
2222
echo "🌐 Starting Clowder (http://localhost:8000) in your default browser"
2323
if ! which xdg-open > /dev/null; then
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
from typing import List
3+
4+
from pyclowder.client import ClowderClient
5+
from termcolor import colored
6+
7+
8+
def main():
9+
# Initialize the client
10+
client = ClowderClient(host="http://localhost:8000", key="bbe2dce9-c3eb-4188-8a70-1d6e676beeb1")
11+
12+
# client.list_datasets()
13+
# datasets = client.get('/datasets/')
14+
# ds_list = [d['name'] for d in datasets]
15+
# print(ds_list)
16+
# save_to_file(ds_list, 'clowder_db')
17+
# for i, dataset in enumerate(datasets):
18+
# print('\t', f'{i}.', dataset['name'])
19+
20+
# or enter a new dataset name, and create a new dataset
21+
22+
# works, but should use CodeFlare instead.
23+
# n = input(
24+
# colored(
25+
# f"👉 Enter the destination filepath on the HPC resource. Your Clowder dataset will be transferred here, and arrive as a folder.",
26+
# "yellow",
27+
# attrs=["bold"]))
28+
# print("You entered", n)
29+
# os.environ['HPC_DESTINATION_PATH'] = n
30+
return
31+
32+
33+
def save_to_file(sentences: List, filename: str):
34+
# Open the file in write mode
35+
with open(filename, "w") as file:
36+
for sentence in sentences:
37+
file.write(sentence)
38+
# ASCII
39+
#.encode(encoding='ascii', errors='ignore').decode()
40+
41+
42+
if __name__ == "__main__":
43+
main()

0 commit comments

Comments
 (0)