The Globus web interface is easy to use, but it may be more convenient to issue commands to Globus directly from the command line of a compute node. It is also possible to create scripts in HPC to transfer a file or directory using Globus-Command-Line-Interface . A few installation and setup steps are required before the first use, which will need both the command line and the web interface, but after setup the commands can be issued from your HPC login session or Slurm script.
Please visit the Quickstart Guide for initial setup steps, and the CLI Command Reference page to learn which commands to use.
Go to the Data Transfer Node (e.g. dtn2). For Markov (class cluster), use markov-transfer.
ssh dtn2
Install Globus CLI in your home directory (using --user flag). Pip can also be upgraded before installing other packages.
module load gcc python/3.8.6
pip3 install --upgrade --user pip globus-cli
(Globus-CLI will install it at /home/<caseID>/.local )
Change directory to .local/bin
cd ~/.local/bin
Test the path for globus-cli. You need to load python module to run the commands.
./globus --help
output:
Usage: globus [OPTIONS] COMMAND [ARGS]...
Options:
-v, --verbose Control level of output
-h, --help Show this message and exit.
...
Note: You may recieve this error in Markov/Rider. RHEL 8 uses openssl-1.1.1, and RHEL 9 uses openssl-3.0.x.
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
Downgrade urllib3 as showed:
pip3 install "urllib3<2" --user
More Help about the commands:
.local/bin/globus endpoint activate --help
output:
Usage: globus endpoint activate [OPTIONS] ENDPOINT_ID
Activate an endpoint using Autoactivation, Myproxy, Delegate Proxy, or Web
activation. Note that --web, --delegate-proxy, and --myproxy activation
...
--myproxy Use myproxy activation. Mutually exclusive
Login to authenticate globus services. It needs to be done only once
./globus login --no-local-server
output:
Please authenticate with Globus here:
------------------------------------
https://auth.globus.org/v2/oauth2/authorize?...Aall
------------------------------------
Enter the resulting Authorization Code here: <Enter the code you get after authentication using the above url>
You have successfully logged in to the Globus CLI!
You can check your primary identity with
globus whoami
For information on which of your identities are in session use
globus session show
Logout of the Globus CLI with
globus logout
(Note: copy and paste the above url to the browser and proceed to get the authentication code that you can enter at the prompt to login in successfully)
Search the HPC Globus server endpoint
./globus endpoint search 'cwru'
output:
ID | Owner | Display Name
------------------------------------ | --------------------- | --------------------------
...
c7f8a02a-d4c8-11e9-939f-02ff96a5aa76 | cwru@globusid.org | cwru#dtn2
cd86e0c0-d56c-11e9-98e2-0a63aa6b37da | cwru@globusid.org | cwru#dtn3
Search your endpoints with the filter
./globus endpoint search --filter-scope my-endpoints
ID | Owner | Display Name
------------------------------------ | ---------------------- | --------------------------
c2bce39e-0192-11e6-a71b-22000bf2d559 | XXXX@globusid.org | XXXX#dtn3
...
Check the home directory associated with the endpoint ID
./globus ls 'a75f9880-f348-11e8-8cc5-xxxxxxxxxxxx'
output:
Custom Office Templates/
MobaXterm/
My Music/
...
Note: During the file transfer, if you receive the message requiring you to activate the endpoint, it is better to activate/authenticate it using the Globus web interface endpoints tab.
Define two endpoint variables ep1 (e.g. sanjayagajurel) and ep2 (e.g. cwru#hpctransfer)
ep1=a75f9880-f348-11e8-8cc5-xxxxxxxxx
ep2=d98c8071-6d04-11e5-ba46-xxxxx
Transfer a single file:
Transfer a file "file.err" from hpctransfer end point to PC endpoint (sanjayagajurel) with a label "CLI test transfer"
./globus transfer $ep2:~/file.err $ep1:~/file.err --label "CLI test transfer"
output:
Message: The transfer has been accepted and a task has been created and queued for execution
Task ID: e1a574cc-f354-11e8-8cc6-0a1d4c5c824a
(Note the Task ID)
Check the status of the transfer using the Task ID
./globus task show 'e1a574cc-f354-11e8-8cc6-xxxxxxx'
output:
Label: CLI test transfer
Task ID:
Is Paused: False
Type: TRANSFER
Files: 1
Status: SUCCEEDED
...
Transfer a directory:
./globus transfer $ep2:~/test $ep1:~/test --recursive --label "CLI test directory transfer"
(Note the --recursive flag & directory name should match)
Transfer batch of files including directories:
Include all the files and directories to be transferred in a input file "in.txt"
test.log test.log
test.out test.out
test test -r # test is a directory and hence recursive flag -r or --recursive
Transfer
./globus transfer $ep2:~/ $ep1:~/ --batch --label "CLI batch transfer" < in.txt
If the endpoint is deactivated, you may get authentication error. So, activate it using:
.local/bin/globus endpoint activate --myproxy <endpoint-globusID>
It will prompt you for the credentials. For HPC endpoints, you need to enter SSO credentials.
Forced Logged Out:
If you want to login as another user
./globus login --no-local-server --force
Case Study - Continuously syncing newly generated files
Use the job script template below to create your job script. For advanced automation, refer to https://github.com/globus/automation-examples/blob/master/
#!/bin/bash
#SBATCH --time=<duration-of-transfer> # set the duration of transfer e.g. 12:00:00 for 12 hrs
# Load the python module
module load python2
#Set Endpoint Task ID for source endpoint ep1 and destination endpoint ep2
ep1=<Task ID for the source endpoint> # e.g. e09e6568-6d04-11e5-ba46-xxxxxxx
ep2=<Task ID for the destination endpoint) # e.g. 0409ae6e-a356-11e9-a379-xxxxxxx
# Infinite Loop until the job terminates after the expiry of the walltime (e.g. 10 hrs)
while true; do
~/.local/bin/globus transfer "$ep1:/<path-to-source-directory>/<directory>/" "$ep2:~/<path-to-source-directory>/<directory>/" --recursive -s 'checksum' --label "CLI delme directory transfer" # <directory> should have same name for src and dest
# wait or sleep for <wait-time> another globus transfer command
sleep <wait-time-for-another-transfer> # e.g 120 for 2 minutes of wait time
done
Now, submit the job
sbatch <your-job-script>
Check the output once the job starts running
cat slurm-<jobID>.out
output:
Message: The transfer has been accepted and a task has been created and queued for execution
Task ID: 8c59a5e0-2276-11ea-ab46-xxxxxxx
Message: The transfer has been accepted and a task has been created and queued for execution
Task ID: d518036c-2276-11ea-9708-xxxxxx
While in progress, the transfer status can be viewed in the Globus web interface's activity tab. If several transfers are happening simultaneously, each can be referenced by the Task ID.
If you get the error message or want to terminate the job in the middle, issue:
scancel <jobID>
$ globus transfer "$ep1:/alignedJPG/" "$ep2:/mnt/vstor/cryoem/test/delme/alignedJPG/" --recursive -s 'checksum' --label "CLI delme directory transfer" --dry-run
Source Path | Dest Path | Recursive
------------ | -------------------------------------- | ---------
/alignedJPG/ | /mnt/vstor/cryoem/test/delme/alignedJPG/ | 1
# or, with JSON output ("-F json" or "--format json")
$ globus transfer "$ep1:/alignedJPG/" "$ep2:/mnt/vstor/cryoem/test/delme/alignedJPG/" --recursive -s 'checksum' --label "CLI delme directory transfer" --dry-run -F json
{
"DATA": [
{
"DATA_TYPE": "transfer_item",
"destination_path": "/mnt/vstor/cryoem/test/delme/alignedJPG/",
"recursive": true,
"source_path": "/alignedJPG/"
}
],
"DATA_TYPE": "transfer",
"delete_destination_extra": false,
"destination_endpoint": "ddb59af0-6d04-11e5-ba46-22000b92c6ec",
"encrypt_data": false,
"label": "CLI delme directory transfer",
"preserve_timestamp": false,
"recursive_symlinks": "ignore",
"skip_activation_check": false,
"source_endpoint": "ddb59aef-6d04-11e5-ba46-22000b92c6ec",
"submission_id": "728ae6a5-5284-11ea-ab5b-0a7959ea6081",
"sync_level": 3,
"verify_checksum": true
}
Issue:
The endpoint could not be auto-activated and must be activated before it can be used.
This endpoint supports the following activation methods: web, delegate proxy, myproxy
For web activation use:
Solution: activate the endpoint from Globus portal using your credentials.
Issue: while using CLI command e.g. ~/.local/bin/globus transfer $ep1:/alignedJPG $ep2:/mnt/vstor/cryoem/test/alignedJPG --recursive -s 'checksum' --label "CLI delme directory transfer", transfer stuck with the warning "warning: is a directory;"
And after using suggested quotes as showed:
~/.local/bin/globus transfer "$ep1:/alignedJPG/" "$ep2:/mnt/vstor/cryoem/test/alignedJPG/" --recursive -s 'checksum' --label "CLI delme directory transfer", error message was:
Globus CLI Error: A Transfer API Error Occurred.
HTTP status: 400
request_id: z863CkFhr
code: ClientError.BadRequest
message: The recursive option should be used when transfering directories
Solution: Some strange characters were being sent to the CLI as showed:
/mnt/vstor/cryoem/test/delme/alignedJPG%C2%A0--recursive
Hence, retyping the command not copying/pasting helped.
~/.local/bin/globus transfer "$ep1:/alignedJPG/" "$ep2:/mnt/vstor/cryoem/test/alignedJPG/" --recursive -s 'checksum' --label "CLI delme directory transfer"