Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesJeffryes committed Mar 28, 2019
0 parents commit 064ad3d
Show file tree
Hide file tree
Showing 30 changed files with 6,296 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test_local
sdk.cfg
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test_local
sdk.cfg
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: python

sudo: required

services:
- docker

branches:
only:
- master

env:

before_install:
- docker version

install:
- pushd ..
- git clone https://github.com/kbase/jars
- git clone https://github.com/kbase/kb_sdk
- cd kb_sdk
- make bin
- make sdkbase
- export PATH=$(pwd)/bin:$PATH
- source src/sh/sdk-completion.sh
- popd

script:
- kb-sdk validate

after_script:
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM kbase/sdkbase2:python
MAINTAINER KBase Developer
# -----------------------------------------
# In this section, you can install any system dependencies required
# to run your App. For instance, you could place an apt-get update or
# install line here, a git checkout to download code, or run any other
# installation scripts.

# RUN apt-get update


# -----------------------------------------

COPY ./ /kb/module
RUN mkdir -p /kb/module/work
RUN chmod -R a+rw /kb/module

WORKDIR /kb/module

RUN make all

ENTRYPOINT [ "./scripts/entrypoint.sh" ]

CMD [ ]
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2015 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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
SERVICE = kb_cobrapy
SERVICE_CAPS = kb_cobrapy
SPEC_FILE = kb_cobrapy.spec
URL = https://kbase.us/services/kb_cobrapy
DIR = $(shell pwd)
LIB_DIR = lib
SCRIPTS_DIR = scripts
TEST_DIR = test
LBIN_DIR = bin
WORK_DIR = /kb/module/work/tmp
EXECUTABLE_SCRIPT_NAME = run_$(SERVICE_CAPS)_async_job.sh
STARTUP_SCRIPT_NAME = start_server.sh
TEST_SCRIPT_NAME = run_tests.sh

.PHONY: test

default: compile

all: compile build build-startup-script build-executable-script build-test-script

compile:
kb-sdk compile $(SPEC_FILE) \
--out $(LIB_DIR) \
--pysrvname $(SERVICE_CAPS).$(SERVICE_CAPS)Server \
--pyimplname $(SERVICE_CAPS).$(SERVICE_CAPS)Impl;

build:
chmod +x $(SCRIPTS_DIR)/entrypoint.sh

build-executable-script:
mkdir -p $(LBIN_DIR)
echo '#!/bin/bash' > $(LBIN_DIR)/$(EXECUTABLE_SCRIPT_NAME)
echo 'script_dir=$$(dirname "$$(readlink -f "$$0")")' >> $(LBIN_DIR)/$(EXECUTABLE_SCRIPT_NAME)
echo 'export PYTHONPATH=$$script_dir/../$(LIB_DIR):$$PATH:$$PYTHONPATH' >> $(LBIN_DIR)/$(EXECUTABLE_SCRIPT_NAME)
echo 'python -u $$script_dir/../$(LIB_DIR)/$(SERVICE_CAPS)/$(SERVICE_CAPS)Server.py $$1 $$2 $$3' >> $(LBIN_DIR)/$(EXECUTABLE_SCRIPT_NAME)
chmod +x $(LBIN_DIR)/$(EXECUTABLE_SCRIPT_NAME)

build-startup-script:
mkdir -p $(LBIN_DIR)
echo '#!/bin/bash' > $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'script_dir=$$(dirname "$$(readlink -f "$$0")")' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'export KB_DEPLOYMENT_CONFIG=$$script_dir/../deploy.cfg' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'export PYTHONPATH=$$script_dir/../$(LIB_DIR):$$PATH:$$PYTHONPATH' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'uwsgi --master --processes 5 --threads 5 --http :5000 --wsgi-file $$script_dir/../$(LIB_DIR)/$(SERVICE_CAPS)/$(SERVICE_CAPS)Server.py' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
chmod +x $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)

build-test-script:
echo '#!/bin/bash' > $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'script_dir=$$(dirname "$$(readlink -f "$$0")")' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export KB_DEPLOYMENT_CONFIG=$$script_dir/../deploy.cfg' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export KB_AUTH_TOKEN=`cat /kb/module/work/token`' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'echo "Removing temp files..."' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'rm -rf $(WORK_DIR)/*' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'echo "...done removing temp files."' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export PYTHONPATH=$$script_dir/../$(LIB_DIR):$$PATH:$$PYTHONPATH' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'cd $$script_dir/../$(TEST_DIR)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'python -m nose --with-coverage --cover-package=$(SERVICE_CAPS) --cover-html --cover-html-dir=/kb/module/work/test_coverage --nocapture --nologcapture .' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
chmod +x $(TEST_DIR)/$(TEST_SCRIPT_NAME)

test:
if [ ! -f /kb/module/work/token ]; then echo -e '\nOutside a docker container please run "kb-sdk test" rather than "make test"\n' && exit 1; fi
bash $(TEST_DIR)/$(TEST_SCRIPT_NAME)

clean:
rm -rfv $(LBIN_DIR)
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# kb_cobrapy

This is a [KBase](https://kbase.us) module generated by the [KBase Software Development Kit (SDK)](https://github.com/kbase/kb_sdk).

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/kb_cobrapy) or its [spec file]($module_name.spec).

# Setup and test

Add your KBase developer token to `test_local/test.cfg` and run the following:

```bash
$ make
$ kb-sdk test
```

After making any additional changes to this repo, run `kb-sdk test` again to verify that everything still works.

# Installation from another module

To use this code in another SDK module, call `kb-sdk install kb_cobrapy` in the other module's root directory.

# Help

You may find the answers to your questions in our [FAQ](https://kbase.github.io/kb_sdk_docs/references/questions_and_answers.html) or [Troubleshooting Guide](https://kbase.github.io/kb_sdk_docs/references/troubleshooting.html).
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# kb_cobrapy release notes
=========================================

0.0.0
-----
* Module created by kb-sdk init
3 changes: 3 additions & 0 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains any reference data required for this module to run that is not already present in KBase.

For any reference data that is too large to host on Github (greater than 100MB), follow the [Reference Data Guide](https://kbase.github.io/kb_sdk_docs/howtos/work_with_reference_data.html) for an alternative.
9 changes: 9 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[ {
"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"
} ]
11 changes: 11 additions & 0 deletions deploy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[kb_cobrapy]
kbase-endpoint = {{ kbase_endpoint }}
job-service-url = {{ job_service_url }}
workspace-url = {{ workspace_url }}
shock-url = {{ shock_url }}
handle-service-url = {{ handle_url }}
srv-wiz-url = {{ srv_wiz_url }}
njsw-url = {{ njsw_url }}
auth-service-url = {{ auth_service_url }}
auth-service-url-allow-insecure = {{ auth_service_url_allow_insecure }}
scratch = /kb/module/work/tmp
16 changes: 16 additions & 0 deletions kb_cobrapy.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
A KBase module: kb_cobrapy
*/

module kb_cobrapy {
typedef structure {
string report_name;
string report_ref;
} ReportResults;

/*
This example function accepts any number of parameters and returns results in a KBaseReport
*/
funcdef run_kb_cobrapy(mapping<string,UnspecifiedObject> params) returns (ReportResults output) authentication required;

};
15 changes: 15 additions & 0 deletions kbase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module-name:
kb_cobrapy

module-description:
A KBase module

service-language:
python

module-version:
0.0.1

owners:
[jjeffryes]

3 changes: 3 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains the module's source code and any installed clients for other SDK modules.

To re-generate any templated source code in this directory, run `make` in the root of this module.
Loading

0 comments on commit 064ad3d

Please sign in to comment.