Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/testing-work.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

build:
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 5
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.9]

env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
Expand All @@ -33,7 +33,9 @@ jobs:
pip install flake8 pytest
pip install pytest-cov
pip install -e .
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -r test_requirements.txt
pip install globus-sdk==1.11.0
pip install globus-nexus-client==0.3.0

- name: Test with pytest
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MDF Connect Client
[![PyPI](https://img.shields.io/pypi/v/mdf_connect_client.svg)](https://pypi.python.org/pypi/mdf-connect-client) [![Build Status](https://travis-ci.org/materials-data-facility/connect_client.svg?branch=master)](https://travis-ci.org/materials-data-facility/connect_client) [![Coverage Status](https://coveralls.io/repos/github/materials-data-facility/connect_client/badge.svg?branch=master)](https://coveralls.io/github/materials-data-facility/connect_client?branch=master) [![Read the Docs](https://readthedocs.org/projects/mdf-connect-client/badge/?version=master)](http://mdf-connect-client.readthedocs.io/en/master/)
[![PyPI](https://img.shields.io/pypi/v/mdf_connect_client.svg)](https://pypi.python.org/pypi/mdf-connect-client) ![Github Actions Tests](https://github.com/materials-data-facility/connect_client/actions/workflows/testing-work.yml/badge.svg)[![Read the Docs](https://readthedocs.org/projects/mdf-connect-client/badge/?version=master)](http://mdf-connect-client.readthedocs.io/en/master/)

The MDF Connect Client is the Python client to easily submit datasets to MDF Connect.

Expand Down
28 changes: 14 additions & 14 deletions mdf_connect_client/mdfcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,13 @@ def submit_dataset(self, update=False, submission=None, reset=False):

# Make the request
headers = {}
self.__authorizer.set_authorization_header(headers)
self.__authorizer.get_authorization_header()
res = requests.post(self.service_loc+self.extract_route,
json=submission, headers=headers)
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.post(self.service_loc+self.extract_route,
json=submission, headers=headers)

Expand Down Expand Up @@ -881,13 +881,13 @@ def submit_dataset_metadata_update(self, source_id, metadata_update=None, reset=

# Make the request
headers = {}
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.post(self.service_loc+self.md_update_route+source_id,
json=metadata_update, headers=headers)
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.post(self.service_loc+self.md_update_route+source_id,
json=metadata_update, headers=headers)

Expand Down Expand Up @@ -945,13 +945,13 @@ def check_status(self, source_id=None, short=False, raw=False):
print("Error: No dataset submitted")
return None
headers = {}
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.status_route+(source_id or self.source_id),
headers=headers)
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.status_route+(source_id or self.source_id),
headers=headers)

Expand Down Expand Up @@ -1079,7 +1079,7 @@ def check_all_submissions(self, verbose=False, active_only=False, include_tests=
filters.append(("submission_time", "<=", older_than_date.isoformat("T") + "Z"))

headers = {}
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
body = {
"filters": filters
}
Expand All @@ -1088,7 +1088,7 @@ def check_all_submissions(self, verbose=False, active_only=False, include_tests=
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.post(url, headers=headers, json=body)

try:
Expand Down Expand Up @@ -1169,12 +1169,12 @@ def get_curation_task(self, source_id, summary=False, raw=False):
if raw is ``True``, *dict*: The full task results.
"""
headers = {}
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.curation_route+source_id, headers=headers)
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.curation_route+source_id, headers=headers)

try:
Expand Down Expand Up @@ -1239,13 +1239,13 @@ def get_available_curation_tasks(self, summary=True, raw=False, _admin_code=None
if raw is ``True``, *dict*: The full task results.
"""
headers = {}
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.all_curation_route+(_admin_code or ""),
headers=headers)
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.all_curation_route+(_admin_code or ""),
headers=headers)
try:
Expand Down Expand Up @@ -1383,13 +1383,13 @@ def _complete_curation_task(self, source_id, verdict, reason, prompt=True, raw=F
"reason": reason
}
headers = {}
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.post(self.service_loc+self.curation_route+source_id, headers=headers,
json=command)
# Handle first 401/403 by regenerating auth headers
if res.status_code == 401 or res.status_code == 403:
self.__authorizer.handle_missing_authorization()
self.__authorizer.set_authorization_header(headers)
headers["Authorization"] = self.__authorizer.get_authorization_header()
res = requests.get(self.service_loc+self.curation_route+source_id, headers=headers,
json=command)

Expand Down
2 changes: 1 addition & 1 deletion mdf_connect_client/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Single source of truth for package version
__version__ = "0.3.8"
__version__ = "0.3.10"
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mdf-toolbox>=0.5.9
globus_sdk==3.2.0
nameparser>=1.0.4
requests>=2.18.4
jsonschema
1 change: 1 addition & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ nbval>=0.9.4
pytest>=5.3.1
pytest-cov>=2.5.1
sphinx_bootstrap_theme>=0.6.5
globus_sdk==2.0.1
2 changes: 2 additions & 0 deletions tests/test_connect_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
client_id = os.getenv('CLIENT_ID')
client_secret = os.getenv('CLIENT_SECRET')


services= [
"data_mdf",
"mdf_connect",
Expand All @@ -24,6 +25,7 @@
client_secret=client_secret,
services=services, make_clients=True)


authorizer = res_cred['mdf_connect']


Expand Down