forked from cvisionai/tator-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_temporary_file.py
34 lines (26 loc) · 1.04 KB
/
upload_temporary_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
""" This example shows how to upload a file as a temporary file. The
file may be an output from an algorithm or similar.
"""
import logging
import sys
import tator
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logger = logging.getLogger(__name__)
if __name__ == '__main__':
# Create a parser that includes path to file to upload.
parser = tator.get_parser()
parser.add_argument('--project_id',
help='Project ID.',
required=True, type=int)
parser.add_argument('--file_path',
help='Path to the file on disk.',
required=True)
args = parser.parse_args()
# Create the api.
tator_api = tator.get_api(args.host, args.token)
# Upload the file.
for progress, response in tator.util.upload_temporary_file(tator_api, args.project_id,
args.file_path):
logger.info(f"Upload progress: {progress}%")
logger.info(response.message)