Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
37838a7
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
47b78dc
Added the noaa_ncep plugin and updated the conda environment file.
Apr 9, 2018
e790d72
NCEP test and setup.cfg were updated.
Apr 9, 2018
00aa22c
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
5ff0e5e
Updated the docs and the python 2 environment file for ncep and terra…
AaronV77 Apr 9, 2018
e0cd550
Minor updates (#38)
AaronV77 Apr 16, 2018
c488638
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
f9121ce
Added the noaa_ncep plugin and updated the conda environment file.
Apr 9, 2018
ab0920b
NCEP test and setup.cfg were updated.
Apr 9, 2018
e48dab0
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
b586e50
Updated the docs and the python 2 environment file for ncep and terra…
AaronV77 Apr 9, 2018
f076882
The setup.cfg never got updated or added to this commit. This fixes t…
AaronV77 Apr 16, 2018
714f2b0
Merge remote-tracking branch 'origin/ncep_provider' into ncep_provider
AaronV77 Apr 16, 2018
649678e
Addeed another service from ncep, and added the sorted call to the li…
AaronV77 Apr 16, 2018
0466a29
Fixed the test and added the sorted functions into this plugin.
AaronV77 Apr 17, 2018
cccb496
Nasa Provider Plugin (#40)
AaronV77 Apr 18, 2018
ff48887
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
6e7f1a8
Added the noaa_ncep plugin and updated the conda environment file.
Apr 9, 2018
9b23c1b
NCEP test and setup.cfg were updated.
Apr 9, 2018
f40a67e
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
2ff755c
Updated the docs and the python 2 environment file for ncep and terra…
AaronV77 Apr 9, 2018
e90f09b
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
3906d87
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
cb32c40
The setup.cfg never got updated or added to this commit. This fixes t…
AaronV77 Apr 16, 2018
34c3623
Addeed another service from ncep, and added the sorted call to the li…
AaronV77 Apr 16, 2018
9133312
Fixed the test and added the sorted functions into this plugin.
AaronV77 Apr 17, 2018
5e3f17e
Fixed the test for ncep provider.
AaronV77 Apr 19, 2018
1f3106e
Merge remote-tracking branch 'origin/ncep_provider' into ncep_provider
AaronV77 Apr 19, 2018
313d6d0
Fixed the test for ncep provider part 2.
AaronV77 Apr 19, 2018
d2af8ab
Updated the authentication to work with QuestWeb, and added a method …
AaronV77 Apr 20, 2018
3289b3e
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
059fec6
Added the noaa_ncep plugin and updated the conda environment file.
Apr 9, 2018
47b067d
NCEP test and setup.cfg were updated.
Apr 9, 2018
fdb30cd
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
e928842
Updated the docs and the python 2 environment file for ncep and terra…
AaronV77 Apr 9, 2018
fa8d7df
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
a5efdef
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
ba74079
The setup.cfg never got updated or added to this commit. This fixes t…
AaronV77 Apr 16, 2018
00bf610
Addeed another service from ncep, and added the sorted call to the li…
AaronV77 Apr 16, 2018
f63a734
Fixed the test and added the sorted functions into this plugin.
AaronV77 Apr 17, 2018
60e4ed3
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
64a6240
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
9d0e1fb
Dataset display name fix (More readable).
AaronV77 Apr 4, 2018
dddc5e9
Removing the placeholder for the girder site.
AaronV77 Apr 9, 2018
a7fe179
Fixed the test for ncep provider.
AaronV77 Apr 19, 2018
0be5eec
Fixed the test for ncep provider part 2.
AaronV77 Apr 19, 2018
290a85b
Merge remote-tracking branch 'origin/ncep_provider' into ncep_provider
Apr 23, 2018
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
9 changes: 3 additions & 6 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Install Released Conda Package

a. Install Quest into new environment::

conda create -n quest -c conda-forge -c erdc quest terrapin
conda create -n quest -c conda-forge -c erdc quest

b. Install Quest into existing environment::

conda install -c erdc -c conda-forge quest terrapin
conda install -c erdc -c conda-forge quest

.. note::

Expand Down Expand Up @@ -49,11 +49,8 @@ Conda Install

Optional
........
d. Some filters (e.g. watershed delineation) require the package `terrapin` that is available through the es-conda-channel::

conda install -c erdc -c conda-forge terrapin

e. Run tests::
d. Run tests::

python setup.py test

Expand Down
5 changes: 4 additions & 1 deletion py2_conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ name: quest

channels:
- conda-forge
- erdc
- defaults

dependencies:
Expand Down Expand Up @@ -40,4 +41,6 @@ dependencies:
- sphinx_rtd_theme
- hs_restclient
- jupyter
- girder-client
- girder-client
- terrapin
- ncep_client
5 changes: 4 additions & 1 deletion py3_conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ name: quest

channels:
- conda-forge
- erdc
- defaults

dependencies:
Expand Down Expand Up @@ -41,4 +42,6 @@ dependencies:
- sphinx_rtd_theme
- hs_restclient
- jupyter
- girder-client
- girder-client
- terrapin
- ncep_client
3 changes: 2 additions & 1 deletion quest/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'download_options',
'get_active_project',
'get_api_version',
'get_auth_status',
'get_collections',
'get_datasets',
'get_features',
Expand Down Expand Up @@ -56,7 +57,6 @@
'save_settings',
'set_active_project',
'stage_for_download',
'stage_for_publish',
'unauthenticate_provider',
'update_metadata', # replaces update_collection, update_feature, update_dataset
'update_settings',
Expand Down Expand Up @@ -150,6 +150,7 @@
get_services,
add_provider,
delete_provider,
get_auth_status,
authenticate_provider,
unauthenticate_provider,
)
Expand Down
4 changes: 2 additions & 2 deletions quest/api/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def download(feature, file_path, dataset=None, **kwargs):


@add_async
def publish(publisher_uri, options=None):
def publish(publisher_uri, **kwargs):
provider, publisher, feature = util.parse_service_uri(publisher_uri)
driver = util.load_providers()[provider]
data = driver.publish(publisher=publisher, options=options)
data = driver.publish(publisher=publisher, **kwargs)
return data

@add_async
Expand Down
30 changes: 26 additions & 4 deletions quest/api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from __future__ import absolute_import
from __future__ import print_function
from ..api.database import get_db, db_session
from .. import util
import os
import requests
Expand Down Expand Up @@ -78,8 +79,6 @@ def get_publishers(expand=None, publisher_type=None):
Returns:
providers (list or dict,Default=list):
list of all available providers


"""
providers = util.load_providers()
publishers = {}
Expand Down Expand Up @@ -127,6 +126,7 @@ def add_provider(uri):
util.update_settings({'USER_SERVICES': user_services})
util.save_settings()
msg = 'service added'
util.load_providers(update_cache=True)
else:
msg = 'service already present'
else:
Expand Down Expand Up @@ -159,13 +159,35 @@ def delete_provider(uri):
util.update_settings({'USER_SERVICES': user_services})
util.save_settings()
msg = 'service removed'
util.load_providers(update_cache=True)
else:
msg = 'service not found'

return msg


def authenticate_provider(uri):
def get_auth_status(uri):
"""Check to see if a provider has been authenticated

Args:
uri (string, Required):
uri of 'user service'
Returns:
True on success
False on not authenticated

"""
db = get_db()
with db_session:
p = db.Providers.select().filter(provider=uri).first()

if p is None:
return False

return True


def authenticate_provider(uri, **kwargs):
"""Authenticate the user.

Args:
Expand All @@ -176,7 +198,7 @@ def authenticate_provider(uri):

"""
driver = util.load_providers()[uri]
driver.authenticate_me()
driver.authenticate_me(**kwargs)


def unauthenticate_provider(uri):
Expand Down
4 changes: 2 additions & 2 deletions quest/services/base/provider_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ def download_options(self, service, fmt):
"""
return self.services[service].download_options(fmt)

def publish(self, publisher, options):
return self.publishers[publisher].publish(options)
def publish(self, publisher, **kwargs):
return self.publishers[publisher].publish(**kwargs)

def publish_options(self, publisher, fmt):
return self.publishers[publisher].publish_options(fmt)
Expand Down
2 changes: 1 addition & 1 deletion quest/services/base/publish_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def publish_options(self, fmt):

return schema

def publish(self, options):
def publish(self, **kwargs):
raise NotImplementedError()
4 changes: 2 additions & 2 deletions quest/services/base/service_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def download_options(self, fmt):

return schema

def download(self, feature, file_path, dataset, **params):
def download(self, feature, file_path, dataset, **kwargs):
raise NotImplementedError()

def get_features(self, **kwargs):
Expand Down Expand Up @@ -138,7 +138,7 @@ class SingleFileServiceBase(ServiceBase):
"""Base file for datasets that are a single file download
eg elevation raster etc
"""
def download(self, feature, file_path, dataset, **params):
def download(self, feature, file_path, dataset, **kwargs):
feature_id = util.construct_service_uri(self.provider.name, self.name, feature)
feature = self.provider.get_features(self.name).loc[feature_id]
reserved = feature.get('reserved')
Expand Down
25 changes: 11 additions & 14 deletions quest/services/cuahsi_hs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from shapely.geometry import Point, box
from ..api.metadata import get_metadata
from ..util import param_util
from getpass import getpass
import pandas as pd
import param
import os


class HSServiceBase(SingleFileServiceBase):

@property
Expand All @@ -35,7 +35,7 @@ class HSGeoService(HSServiceBase):

def get_features(self, **kwargs):

results = list(self.hs.resources())
results = list(self.hs.resources(coverage_type="box", north="90", south="-90", east="180", west="-180"))

if len(results) == 0:
raise ValueError('No resource available from HydroShare.')
Expand Down Expand Up @@ -126,21 +126,18 @@ class HSPublisher(PublishBase):
'Time Series': 'TimeSeriesResource'
}

title = param.String(default="example title", doc="Title of resource", precedence=2)
abstract = param.String(default="example abstract", precedence=3,
doc="An description of the resource to be added to HydroShare.")
keywords = param.List(default=[], precedence=4, doc="list of keyword strings to describe the resource")
dataset = param_util.DatasetListSelector(default=(), filters={'status': 'downloaded'}, precedence=5,
doc="dataset to publish to HydroShare")
resource_type = param.ObjectSelector(doc='parameter', precedence=1, objects=sorted(_resource_type_map.keys()))
resource_type = param.ObjectSelector(default=None, doc="", precedence=1, objects=sorted(_resource_type_map.keys()))
title = param.String(default="", doc="", precedence=2)
abstract = param.String(default="", doc="", precedence=3)
keywords = param.List(default=[], doc="", precedence=4)
dataset = param_util.DatasetListSelector(default=(), filters={'status': 'downloaded'}, doc="", precedence=5)

@property
def hs(self):
return self.provider.get_hs()

def publish(self, options=None):

p = param.ParamOverrides(self, options)
def publish(self, **kwargs):
p = param.ParamOverrides(self, kwargs)
valid_file_paths = []
valid_extensions = []

Expand Down Expand Up @@ -262,8 +259,8 @@ def get_hs(self, auth=None, require_valid_auth=False):

def authenticate_me(self, **kwargs):

username = input("Enter Username: ")
password = getpass("Enter Password: ")
username = kwargs['username']
password = kwargs['password']

try:
auth = HydroShareAuthBasic(username=username, password=password)
Expand Down
8 changes: 4 additions & 4 deletions quest/services/kitware_girder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class GirderPublisher(PublishBase):
def gc(self):
return self.provider.get_gc()

def publish(self, options=None):
def publish(self, **kwargs):
try:
p = param.ParamOverrides(self, options)
p = param.ParamOverrides(self, kwargs)
params = {'name': p.title, 'description': p.collection_description}
resource_information_dict = self.gc.createResource(path='collection', params=params)
folder_creation_dict = self.gc.createFolder(parentId=resource_information_dict['_id'],
Expand Down Expand Up @@ -77,8 +77,8 @@ def get_gc(self):

def authenticate_me(self, **kwargs):
connection_info = 'https://data.kitware.com/api/v1'
username = input("Enter Username: ")
password = getpass("Enter Password: ")
username = kwargs['username']
password = kwargs['password']

try:
gc = girder_client.GirderClient(apiUrl=connection_info)
Expand Down
45 changes: 43 additions & 2 deletions quest/services/nasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

"""
from .base import ProviderBase, SingleFileServiceBase
from ..api.database import get_db, db_session
from getpass import getpass
import pandas as pd
import requests

Expand All @@ -20,8 +22,15 @@ class NasaServiceBase(SingleFileServiceBase):
'elevation': 'elevation'
}

def _read_granules(short_name, page_num):
return requests.get(granules_url % (short_name, page_num)).json()['feed']['entry']
@property
def info(self):
return self.provider.get_user_info()

def _read_granules(self, short_name, page_num):
try:
return requests.get(granules_url % (short_name, page_num), auth=(self.info['username'], self.info['password'])).json()['feed']['entry']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501 line too long (147 > 120 characters)

except ValueError:
return requests.get(granules_url % (short_name, page_num)).json()['feed']['entry']

def get_features(self, **kwargs):
page_num = 0
Expand Down Expand Up @@ -128,3 +137,35 @@ class NasaProvider(ProviderBase):
description = 'Services available through the NASA'
organization_name = 'National Aeronautic and Space Administration'
organization_abbr = 'NASA'

def get_user_info(self):
the_info = self.credentials
return the_info

def authenticate_me(self, **kwargs):

username = input("Enter Username: ")
password = getpass("Enter Password: ")

try:
db = get_db()
with db_session:
p = db.Providers.select().filter(provider=self.name).first()

provider_metadata = {
'provider': self.name,
'username': username,
'password': password,
}

if p is None:
db.Providers(**provider_metadata)
else:
p.set(**provider_metadata)

return True

except:
print("Either credentials invalid or unable to connect to HydroShare.")

return False
4 changes: 2 additions & 2 deletions quest/services/noaa_coastwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def parameter_map(self, invert=False):

return pmap

def download(self, feature, file_path, dataset, **params):
p = param.ParamOverrides(self, params)
def download(self, feature, file_path, dataset, **kwargs):
p = param.ParamOverrides(self, kwargs)
self.parameter = p.parameter
self.end = pd.to_datetime(p.end)
self.start = pd.to_datetime(p.start)
Expand Down
4 changes: 2 additions & 2 deletions quest/services/noaa_ncdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def parameter_map(self, invert=False):

return pmap

def download(self, feature, file_path, dataset, **params):
p = param.ParamOverrides(self, params)
def download(self, feature, file_path, dataset, **kwargs):
p = param.ParamOverrides(self, kwargs)
self.parameter = p.parameter
self.end = pd.to_datetime(p.end)
self.start = pd.to_datetime(p.start)
Expand Down
Loading