Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bloodeagle40234
Created September 5, 2016 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloodeagle40234/4ca4375131e35e788d45dbc2e29467a3 to your computer and use it in GitHub Desktop.
Save bloodeagle40234/4ca4375131e35e788d45dbc2e29467a3 to your computer and use it in GitHub Desktop.
diff --git a/StorletSamples/python/simple/simple.py b/StorletSamples/python/simple/simple.py
index df5d807..740b708 100644
--- a/StorletSamples/python/simple/simple.py
+++ b/StorletSamples/python/simple/simple.py
@@ -13,8 +13,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+class StorletAppTemplate(object):
+ def __call__(self, in_md, in_files, out_md_files, out_files, params):
+ """
+ :param in_md: a dict of input metadata (why this is just a dict?)
+ :param in_files: a list of input file objects to read
+ :param out_md_files: a list of md??? <- why we need this as a list?
+ :param out_files: a list of file-like objects to write
+ :param params: a dict of query_args
+ """
+ out_md, out_files = self.invoke(in_md, in_files)
+ out_md_files[0].write(json.dumps(out_md))
+ out_md_files[0].close()
+ # translation from out_files from invoke to out_files for upper abstraction
+ # TODOTODOTOD
+
-class SimpleStorlet(object):
+ def invoke(self, in_md, in_files, params):
+ """
+ All storlet app should implement this invocation method
+ :param in_md: a dict of input metadata (why this is just a dict?)
+ :param in_files: a list of input file objects to read
+ :param out_md_files: a list of md??? <- why we need this as a list?
+ :param out_files: a list of file-like objects to write
+ :param params: a dict of query_args
+
+ :return: a tuple of (out_md, out_files)
+ """
+ raise NotImplementedError()
+
+
+class SimpleStorlet(StorletAppTemplate):
def __init__(self, logger):
self.logger = logger
@@ -26,7 +55,12 @@ class SimpleStorlet(object):
# TODO(takashi): This is just for drafting interface
raise NotImplementedError()
- def __call__(self, in_md, in_files, out_md_files, out_files, params):
+ def invoke(self, in_md, in_files, params):
+ """
+ :param in_md: a dict of input metadata (why this is just a dict?)
+ :param in_files: a list of input file objects to read
+ :param params: a dict of query_args
+ """
self.logger.debug('Returning metadata')
metadata = in_md[0]
metadata['test'] = 'simple'
@@ -48,3 +82,4 @@ class SimpleStorlet(object):
self.logger.debug('Complete')
in_files[0].close()
out_files[0].close()
+ return out_md_files, out_files # out_md_files should be out_md dict?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment