<jupyter_start><jupyter_text>The following code uses the Globus Python SDK to submit a data transfer from the NCAR GLADE endpoint to the NCAR Campaign Storage endpoint.  The client app is instantiated using refresh tokens that have already been created and stored in a secure file. For more information, see the tutorial provided on the Globus Python SDK documentation pages at https://globus-sdk-python.readthedocs.io/en/stable/tutorial/<jupyter_code>from globus_sdk import *
import json<jupyter_output><empty_output><jupyter_text>Read in refresh tokens from secure file Tokens are stored in JSON format in this example<jupyter_code>globus_auth_infile = '<PATH-TO-GLOBUS-AUTH-TOKEN-FILE>'
globus_transfer_infile = '<PATH-TO-GLOBUS-TRANSFER-TOKEN-FILE>'
with open(globus_auth_infile) as auth_file:  
    globus_auth_data = json.load(auth_file)
with open(globus_transfer_infile) as transfer_file:
    globus_transfer_data = json.load(transfer_file)
# most specifically, you want these tokens as strings
TRANSFER_TOKEN = globus_transfer_data['access_token']
TRANSFER_RT = globus_transfer_data['refresh_token']
TRANSFER_EXPIRES_AT = globus_transfer_data['expires_at_seconds']

AUTH_TOKEN = globus_auth_data['access_token']
AUTH_RT = globus_auth_data['refresh_token']
AUTH_EXPIRES_AT = globus_auth_data['expires_at_seconds']<jupyter_output><empty_output><jupyter_text>Print the Transfer data<jupyter_code>for a in globus_transfer_data:
    print (a,':',globus_transfer_data[a])<jupyter_output><empty_output><jupyter_text>Instantitate the transfer client using your refresh token<jupyter_code>CLIENT_ID = '<YOUR-CLIENT-ID>'
client = NativeAppAuthClient(CLIENT_ID)

tc_authorizer = RefreshTokenAuthorizer(TRANSFER_RT, client)
tc = TransferClient(authorizer=tc_authorizer)<jupyter_output><empty_output><jupyter_text>Search for the NCAR GLADE and NCAR Campaign Store endpoints and get the endpoint IDs<jupyter_code>source_endpoint = tc.endpoint_search('NCAR GLADE')[0]['id']
destination_endpoint = tc.endpoint_search('NCAR Campaign Storage')[0]['id']<jupyter_output><empty_output><jupyter_text>Create transfer data object containing the data to be transferred<jupyter_code>transfer_data = TransferData(transfer_client=tc,
							 source_endpoint=source_endpoint,
							 destination_endpoint=destination_endpoint,
							 label='NCAR example transfer')<jupyter_output><empty_output><jupyter_text>Add files or directories to be transferred.  Note source_path is relative to the source endpoint base path.<jupyter_code>source_files = ['file1.txt', 'file2.txt', 'file3.txt']

source_path = '/<DIRECTORY-PATH-ON-GLADE>/'
dest_path = '/<DIRECTORY-PATH-ON-NCAR-CAMPAIGN-STORAGE>/'

for file in source_files:
    source_file = "{0}{1}".format(source_path, source_files[file])
    dest_file = "{0}{1}".format(dest_path, source_files[file])
    transfer_data.add_item(source_file, dest_file)<jupyter_output><empty_output><jupyter_text>Activate both the source and destination endpoints<jupyter_code>tc.endpoint_autoactivate(source_endpoint)
tc.endpoint_autoactivate(destination_endpoint)<jupyter_output><empty_output><jupyter_text>Submit the transfer and print the task ID<jupyter_code>task_id = tc.submit_transfer(transfer_data)
print "Task ID: {}".format(task_id['task_id'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09425357251444208, 'fraction_numerical': 0.002736394040741867, 'mean_word_length': 8.189944134078212, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 42, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '589232', 'license': 'MIT', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1064, 'n_words': 225, 'path': 'docs/Jupyter-notebooks/NCAR Campaign Store transfer example using refresh tokens.ipynb', 'repo_name': 'NCAR/rda-globus', 'size': '3289'}