Skip to content

Commit 8ed5925

Browse files
authored
Merge pull request #51 from materials-data-facility/forge-dev
Merge Forge dev to master
2 parents 3824d0f + 8bf490c commit 8ed5925

7 files changed

Lines changed: 43 additions & 15 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python:
33
- '3.5'
44
- '3.6'
55
- '3.7'
6+
- '3.8'
67
install:
78
- pip install --upgrade pip
89
- pip install -e .

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ Tutorials and examples can be found in the `docs` directory. The Jupyter noteboo
2828
* To access data in the MDF, you must have an account recognized by Globus Auth (including Google, ORCiD, many academic institutions, or a [free Globus ID](https://www.globusid.org/create)).
2929

3030
# Contributions
31-
If you find a bug or want a feature, feel free to open an issue here on GitHub (and please tag it accordingly). If you want to contribute code yourself, we're more than happy to accept merge requests.
32-
33-
31+
If you find a bug or want a feature, feel free to open an issue here on GitHub (and please tag it accordingly). If you want to contribute code yourself, we're more than happy to accept pull requests. Please direct these pull requests to the `forge-dev` branch
3432

3533
# Support
3634
This work was performed under financial assistance award 70NANB14H012 from U.S. Department of Commerce, National Institute of Standards and Technology as part of the [Center for Hierarchical Material Design (CHiMaD)](http://chimad.northwestern.edu). This work was performed under the following financial assistance award 70NANB19H005 from U.S. Department of Commerce, National Institute of Standards and Technology as part of the Center for Hierarchical Materials Design (CHiMaD). This work was also supported by the National Science Foundation as part of the [Midwest Big Data Hub](http://midwestbigdatahub.org) under NSF Award Number: 1636950 "BD Spokes: SPOKE: MIDWEST: Collaborative: Integrative Materials Design (IMaD): Leverage, Innovate, and Disseminate".

mdf_forge/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from .forge import Forge # noqa: F401
2+
from .version import __version__ # noqa: F401

mdf_forge/forge.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import globus_sdk
66
import mdf_toolbox
77
import requests
8-
9-
108
from tqdm import tqdm
119

10+
from .version import __version__
11+
1212
# Maximum recommended number of HTTP file transfers
1313
# Large transfers are much better suited for Globus Transfer
1414
HTTP_NUM_LIMIT = 50
@@ -70,6 +70,14 @@ def __init__(self, index=__default_index, local_ep=None, anonymous=False,
7070
to overwrite the default for accessing the MDF NCSA endpoint.
7171
petrel_authorizer (globus_sdk.GlobusAuthorizer): An authenticated GlobusAuthorizer
7272
to override the default.
73+
no_local_server (bool): Disable spinning up a local server to automatically
74+
copy-paste the auth code. THIS IS REQUIRED if you are on a remote server.
75+
When used locally with no_local_server=False, the domain is localhost with
76+
a randomly chosen open port number.
77+
**Default**: ``False``.
78+
no_browser (bool): Do not automatically open the browser for the Globus Auth URL.
79+
Display the URL instead and let the user navigate to that location manually.
80+
**Default**: ``False``.
7381
"""
7482
self.__anonymous = anonymous
7583
self.local_ep = local_ep
@@ -82,7 +90,9 @@ def __init__(self, index=__default_index, local_ep=None, anonymous=False,
8290
if services:
8391
clients = mdf_toolbox.login(services=services, app_name=self.__app_name,
8492
client_id=self.__client_id,
85-
clear_old_tokens=clear_old_tokens)
93+
clear_old_tokens=clear_old_tokens,
94+
no_local_server=kwargs.get("no_local_server", False),
95+
no_browser=kwargs.get("no_browser", False))
8696
else:
8797
clients = {}
8898

@@ -97,6 +107,10 @@ def __init__(self, index=__default_index, local_ep=None, anonymous=False,
97107
super().__init__(index=index, search_client=search_client,
98108
scroll_field=self.__scroll_field, **kwargs)
99109

110+
@property
111+
def version(self):
112+
return __version__
113+
100114
# ***********************************************
101115
# * Field-specific helpers
102116
# ***********************************************
@@ -636,7 +650,7 @@ def http_download(self, results, dest=".", preserve_dir=False, verbose=True):
636650
}
637651

638652
def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False,
639-
inactivity_time=None, download_datasets=False, verbose=True):
653+
download_datasets=False, verbose=True, **kwargs):
640654
"""Download data files from the provided results using Globus Transfer.
641655
This method requires Globus Connect to be installed on the destination endpoint.
642656
@@ -651,9 +665,6 @@ def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False,
651665
will be relative to the ``dest`` path
652666
If ``False``, only the data files themselves will be saved.
653667
**Default:** ``False``.
654-
inactivity_time (int): Number of seconds the Transfer is allowed to go without progress
655-
before being cancelled.
656-
**Default:** ``self.__inactivity_time``.
657668
download_datasets (bool): If ``True``, will download the full dataset for any dataset
658669
entries given.
659670
If ``False``, will skip dataset entries with a notification.
@@ -668,7 +679,14 @@ def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False,
668679
and errors will prompt for continuation confirmation.
669680
If ``False``, only error messages will be printed,
670681
and the Transfer will always continue.
671-
**Default:** ``True``.
682+
**Default:** ``False``.
683+
684+
Keyword Arguments:
685+
inactivity_time (int): Number of seconds the Transfer is allowed to go without progress
686+
before being cancelled.
687+
**Default:** ``self.__inactivity_time``.
688+
interval (int): Time in seconds to wait between checking transfer status.
689+
**Default:** ``self.__transfer_interval``
672690
673691
Returns:
674692
list of str: The task IDs of the Globus transfers.
@@ -679,6 +697,9 @@ def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False,
679697
"success": False,
680698
"message": "Anonymous Globus Transfer not supported."
681699
}
700+
inactivity_time = kwargs.get("inactivity_time", self.__inactivity_time)
701+
interval = kwargs.get('interval', self.__transfer_interval)
702+
682703
dest = os.path.abspath(dest)
683704
# If results have info attached, remove it
684705
if type(results) is tuple:
@@ -687,8 +708,6 @@ def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False,
687708
if not self.local_ep:
688709
self.local_ep = globus_sdk.LocalGlobusConnectPersonal().endpoint_id
689710
dest_ep = self.local_ep
690-
if not inactivity_time:
691-
inactivity_time = self.__inactivity_time
692711

693712
# Assemble the transfer data
694713
tasks = {}
@@ -772,7 +791,7 @@ def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False,
772791
for task_ep, task_paths in tqdm(tasks.items(), desc="Transferring data",
773792
disable=(not verbose)):
774793
transfer = mdf_toolbox.custom_transfer(self.__transfer_client, task_ep, dest_ep,
775-
task_paths, interval=self.__transfer_interval,
794+
task_paths, interval=interval,
776795
inactivity_time=inactivity_time)
777796
cont = True
778797
# Prime loop

mdf_forge/version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Single source of truth for package version
2+
__version__ = "0.7.6"

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import os
12
from setuptools import setup
23

4+
# Single source of truth for version
5+
version_ns = {}
6+
with open(os.path.join("mdf_forge", "version.py")) as f:
7+
exec(f.read(), version_ns)
8+
version = version_ns['__version__']
9+
310
setup(
411
name='mdf_forge',
5-
version='0.7.5',
12+
version=version,
613
packages=['mdf_forge'],
714
description='Materials Data Facility python package',
815
long_description=("Forge is the Materials Data Facility Python package"

travis.tar.enc

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)