-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# !usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under a 3-clause BSD license. | ||
# | ||
# @Author: Brian Cherinka | ||
# @Date: 2018-06-21 15:11:40 | ||
# @Last modified by: Brian Cherinka | ||
# @Last Modified time: 2018-06-21 17:18:21 | ||
|
||
from __future__ import print_function, division, absolute_import | ||
import pkgutil | ||
import importlib | ||
import os | ||
|
||
|
||
pkg_dir = os.path.dirname(__file__) | ||
for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]): | ||
if name != 'base': | ||
importlib.import_module('marvin.contrib.vacs.{0}'.format(name), __package__) | ||
|
||
|
||
from marvin.contrib.vacs.base import VACMixIn | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# !usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under a 3-clause BSD license. | ||
# | ||
# @Author: Brian Cherinka | ||
# @Date: 2018-06-21 17:01:09 | ||
# @Last modified by: Brian Cherinka | ||
# @Last Modified time: 2018-06-22 11:22:39 | ||
|
||
from __future__ import print_function, division, absolute_import | ||
import abc | ||
import six | ||
import time | ||
import os | ||
from marvin.core.exceptions import MarvinError | ||
from sdss_access.sync import RsyncAccess | ||
|
||
|
||
class VACMixIn(object, six.with_metaclass(abc.ABCMeta)): | ||
''' This mixin allows for integrating a VAC into Marvin ''' | ||
|
||
@abc.abstractmethod | ||
def _get_from_file(self): | ||
''' This method controls accessing a VAC from a local file ''' | ||
pass | ||
|
||
def download_vac(self, name=None, **path_params): | ||
"""Download the VAC using rsync """ | ||
|
||
if 'MANGA_SANDBOX' not in os.environ: | ||
os.environ['MANGA_SANDBOX'] = os.path.join(os.getenv("SAS_BASE_DIR"), 'mangawork/manga/sandbox') | ||
|
||
if not RsyncAccess: | ||
raise MarvinError('sdss_access is not installed') | ||
else: | ||
rsync_access = RsyncAccess() | ||
rsync_access.remote() | ||
rsync_access.add(name, **path_params) | ||
rsync_access.set_stream() | ||
rsync_access.commit() | ||
paths = rsync_access.get_paths() | ||
time.sleep(0.001) # adding a millisecond pause for download to finish and file extistence to register | ||
self.filename = paths[0] # doing this for single files, may need to change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# !usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under a 3-clause BSD license. | ||
# | ||
# @Author: Brian Cherinka | ||
# @Date: 2018-06-21 15:13:07 | ||
# @Last modified by: Brian Cherinka | ||
# @Last Modified time: 2018-06-21 19:08:03 | ||
|
||
from __future__ import print_function, division, absolute_import | ||
|
||
from marvin.contrib.vacs.base import VACMixIn | ||
from sdss_access.path import Path | ||
|
||
|
||
class DapVAC(VACMixIn): | ||
|
||
def _get_from_file(self): | ||
self._filename = Path().full('dapall', dapver='2.1.3', drpver='v2_3_1') | ||
|
||
@property | ||
def dap_vac_row(self): | ||
return {'ddapvac': 'dfdf', 'stuff': self.plateifu} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# !usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under a 3-clause BSD license. | ||
# | ||
# @Author: Brian Cherinka | ||
# @Date: 2018-06-21 18:57:07 | ||
# @Last modified by: Brian Cherinka | ||
# @Last Modified time: 2018-06-21 19:07:00 | ||
|
||
from __future__ import print_function, division, absolute_import | ||
from marvin.contrib.vacs.base import VACMixIn | ||
from sdss_access.path import Path | ||
|
||
|
||
class TestVAC(VACMixIn): | ||
|
||
def _get_from_file(self): | ||
self._filename = Path().full('dapall', dapver='2.1.3', drpver='v2_3_1') | ||
|
||
@property | ||
def test_vac_row(self): | ||
return {'testvac': 'this is a test'} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters