Skip to content
Merged
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 The KBase Project and its Contributors
Copyright (c) 2019 The KBase Project and its Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is a [KBase](https://kbase.us) module generated by the [KBase Software Deve

You will need to have the SDK installed to use this module. [Learn more about the SDK and how to use it](https://kbase.github.io/kb_sdk_docs/).

You can also learn more about the apps implemented in this module from its [catalog page](https://narrative.kbase.us/#catalog/modules/SampleService) or its [spec file]($module_name.spec).
You can also learn more about the apps implemented in this module from its [catalog page](https://narrative.kbase.us/#catalog/modules/SampleService) or its [spec file](SampleService.spec).

# Setup and test

Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SampleService release notes
=========================================

0.0.0
0.1.0
-----
* Module created by kb-sdk init
68 changes: 61 additions & 7 deletions SampleService.spec
Original file line number Diff line number Diff line change
@@ -1,16 +1,70 @@
/*
A KBase module: SampleService

Handles creating, updating, retriving samples and linking data to samples.
*/

module SampleService {

/* A key in a metadata key/value pair. Less than 1000 unicode characters. */
typedef string metadata_key;

/* A value in a metadata key/value pair. Less than 1000 unicode characters. */
typedef string metadata_value;

/* Units for a quantity, e.g. km, mol/g, ppm, etc.
'None' for unitless quantities.
Less than 50 unicode characters.
*/
typedef string units;

/* A SampleNode ID. Must be unique within a Sample, contain only the characters
[a-zA-Z0-9_], and be less than 255 characters.
*/
typedef string node_id;

/* A Sample ID. Must be globally unique. Always assigned by the Sample service. */
typedef string sample_id;

/* The version of a sample. Always > 0. */
typedef int version;

/* Metadata attached to a sample. */
typedef mapping<metadata_key, tuple<metadata_value, units>> metadata;

/* A node in a sample tree.
id - the ID of the node.
meta_controlled - metadata restricted by the sample controlled vocabulary and validators.
meta_user - unrestricted metadata.
*/
typedef structure {
string report_name;
string report_ref;
} ReportResults;
node_id id;
metadata meta_controlled;
metadata meta_user;
} SampleNode;

/*
This example function accepts any number of parameters and returns results in a KBaseReport
*/
funcdef run_SampleService(mapping<string,UnspecifiedObject> params) returns (ReportResults output) authentication required;
/* A Sample, consisting of a tree of subsamples and replicates.
id - the ID of the sample.
single_node - the node in a single node tree.
*/
typedef structure {
sample_id id;
SampleNode single_node;
} Sample;

/* A Sample ID and version.
id - the ID of the sample.
version - the version of the sample.
*/
typedef structure {
sample_id id;
version version;
} SampleAddress;

/* Create a new sample or a sample version.
If Sample.id is null, a new Sample is created along with a new ID.
Otherwise, a new version of Sample.id is created. If Sample.id does not exist, an error
is returned.
*/
funcdef create_sample(Sample sample) returns(SampleAddress address) authentication required;
};
3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* coverage
* https://github.com/kbaseIncubator/samples/pull/1/files
* The ~10 documents that have been written about this
4 changes: 0 additions & 4 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[ {
"module_name" : "KBaseReport",
"type" : "sdk",
"version_tag" : "release"
}, {
"module_name" : "Workspace",
"type" : "core",
"file_path" : "https://raw.githubusercontent.com/kbase/workspace_deluxe/master/workspace.spec"
Expand Down
4 changes: 2 additions & 2 deletions kbase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module-name:
SampleService

module-description:
A KBase module
Handles creating, updating, retriving samples and linking data to samples.

service-language:
python

module-version:
0.0.1
0.1.0-alpha1

owners:
[gaprice]
Expand Down
67 changes: 46 additions & 21 deletions lib/SampleService/SampleServiceImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class SampleService:

Module Description:
A KBase module: SampleService

Handles creating, updating, retriving samples and linking data to samples.
'''

######## WARNING FOR GEVENT USERS ####### noqa
Expand All @@ -24,7 +26,7 @@ class SampleService:
######################################### noqa
VERSION = "0.0.1"
GIT_URL = "https://github.com/mrcreosote/sample_service.git"
GIT_COMMIT_HASH = "3bac7cdfc9fe72b5a8b807eb80248c32e2b7929b"
GIT_COMMIT_HASH = "c63c061ffbc6f2aef594a7fbdcd07badd8bf4c2a"

#BEGIN_CLASS_HEADER
#END_CLASS_HEADER
Expand All @@ -41,32 +43,55 @@ def __init__(self, config):
pass


def run_SampleService(self, ctx, params):
def create_sample(self, ctx, sample):
"""
This example function accepts any number of parameters and returns results in a KBaseReport
:param params: instance of mapping from String to unspecified object
:returns: instance of type "ReportResults" -> structure: parameter
"report_name" of String, parameter "report_ref" of String
Create a new sample or a sample version.
If Sample.id is null, a new Sample is created along with a new ID.
Otherwise, a new version of Sample.id is created. If Sample.id does not exist, an error
is returned.
:param sample: instance of type "Sample" (A Sample, consisting of a
tree of subsamples and replicates. id - the ID of the sample.
single_node - the node in a single node tree.) -> structure:
parameter "id" of type "sample_id" (A Sample ID. Must be globally
unique. Always assigned by the Sample service.), parameter
"single_node" of type "SampleNode" (A node in a sample tree. id -
the ID of the node. meta_controlled - metadata restricted by the
sample controlled vocabulary and validators. meta_user -
unrestricted metadata.) -> structure: parameter "id" of type
"node_id" (A SampleNode ID. Must be unique within a Sample,
contain only the characters [a-zA-Z0-9_], and be less than 255
characters.), parameter "meta_controlled" of type "metadata"
(Metadata attached to a sample.) -> mapping from type
"metadata_key" (A key in a metadata key/value pair. Less than 1000
unicode characters.) to tuple of size 2: type "metadata_value" (A
value in a metadata key/value pair. Less than 1000 unicode
characters.), type "units" (Units for a quantity, e.g. km, mol/g,
ppm, etc. 'None' for unitless quantities. Less than 50 unicode
characters.), parameter "meta_user" of type "metadata" (Metadata
attached to a sample.) -> mapping from type "metadata_key" (A key
in a metadata key/value pair. Less than 1000 unicode characters.)
to tuple of size 2: type "metadata_value" (A value in a metadata
key/value pair. Less than 1000 unicode characters.), type "units"
(Units for a quantity, e.g. km, mol/g, ppm, etc. 'None' for
unitless quantities. Less than 50 unicode characters.)
:returns: instance of type "SampleAddress" (A Sample ID and version.
id - the ID of the sample. version - the version of the sample.)
-> structure: parameter "id" of type "sample_id" (A Sample ID.
Must be globally unique. Always assigned by the Sample service.),
parameter "version" of type "version" (The version of a sample.
Always > 0.)
"""
# ctx is the context object
# return variables are: output
#BEGIN run_SampleService
report = KBaseReport(self.callback_url)
report_info = report.create({'report': {'objects_created':[],
'text_message': params['parameter_1']},
'workspace_name': params['workspace_name']})
output = {
'report_name': report_info['name'],
'report_ref': report_info['ref'],
}
#END run_SampleService
# return variables are: address
#BEGIN create_sample
#END create_sample

# At some point might do deeper type checking...
if not isinstance(output, dict):
raise ValueError('Method run_SampleService return value ' +
'output is not type dict as required.')
if not isinstance(address, dict):
raise ValueError('Method create_sample return value ' +
'address is not type dict as required.')
# return the results
return [output]
return [address]
def status(self, ctx):
#BEGIN_STATUS
returnVal = {'state': "OK",
Expand Down
Loading