Skip to content

Commit

Permalink
[RAW] functional pipeline graph editor, added docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
achillesrasquinha committed Jul 19, 2017
1 parent 6529e2a commit bce308d
Show file tree
Hide file tree
Showing 20 changed files with 986 additions and 882 deletions.
File renamed without changes
Binary file removed .github/logo.png
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src=".github/logo.png" width="512">
<img src=".github/logo-title.png" width="512">
</div>

---
Expand Down
2 changes: 1 addition & 1 deletion candis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# module - candis
from candis.config import Config, get_config, CONFIG
from candis.manager import Cache
from candis.data import entrez
# from candis.data import entrez
from candis.ios import cdata, pipeline
from candis.cli import main

Expand Down
1,468 changes: 743 additions & 725 deletions candis/app/assets/js/bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion candis/app/client/app/action/AsynchronousAction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getResource = (dispatch) => {
})
}

const write = (output, format, buffer = { }) => {
const write = (output, format, buffer = null) => {
const dispatch = (dispatch) => {
const action = requestWrite(output, format, buffer)
const parameters = { output: output, format: format, buffer: buffer }
Expand Down
6 changes: 3 additions & 3 deletions candis/app/client/app/action/DocumentProcessorAction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const removeDocument = (dokument) => {
return action
}

const pushStage = (stage) => {
const setStage = (stage) => {
const action = {
type: ActionType.DocumentProcessor.PUSH_STAGE,
type: ActionType.DocumentProcessor.SET_STAGE,
payload: stage
}

return action
}

export { setActiveDocument, removeDocument, pushStage }
export { setActiveDocument, removeDocument, setStage }
6 changes: 3 additions & 3 deletions candis/app/client/app/component/widget/GraphEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GraphEditor extends React.Component {

return (
<div className={classNames("panel panel-default no-border no-shadow no-background")}>
<div className="panel-body" style={{ height: "100vh" }}>
<div className="panel-body" style={{ height: "100%" }}>
{
graph.nodes().map((ID, index) => {
let meta = graph.node(ID)
Expand All @@ -26,7 +26,7 @@ class GraphEditor extends React.Component {
<span>
<h2 className="no-margin">
<span className="label label-default">
{meta.label}
{meta.name}
</span>
</h2>
</span>
Expand All @@ -48,4 +48,4 @@ const mapStateToProps = (state) => {
}
}

export default connect(mapStateToProps)(GraphEditor)
export default connect()(GraphEditor)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class DocumentPanel extends React.Component {
</div>
<div className="panel-body">
{

active ?
<GraphEditor
graph={active.data}/> : null
}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion candis/app/client/app/constant/ActionType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ActionType =
{
SET_ACTIVE_DOCUMENT: 'ACTION_TYPE_SET_ACTIVE_DOCUMENT',
REMOVE_DOCUMENT: 'ACTION_TYPE_DOCUMENT_PROCESSOR_REMOVE_DOCUMENT',
PUSH_STAGE: 'ACTION_TYPE_DOCUMENT_PUSH_STAGE'
SET_STAGE: 'ACTION_TYPE_DOCUMENT_SET_STAGE'
},

INSERT_TOOL: 'ACTION_TYPE_INSERT_TOOL',
Expand Down
8 changes: 4 additions & 4 deletions candis/app/client/app/meta/Compartments.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'
import axios from 'axios'

import config from '../config'
import { pushStage } from '../action/DocumentProcessorAction'
import config from '../config'
import { setStage } from '../action/DocumentProcessorAction'

import { showDialog, hideDialog } from '../action/DialogAction'
import Dialog from '../component/widget/Dialog'
Expand All @@ -18,7 +18,7 @@ const Compartments = [
icon: `${config.routes.icons}/edit.png`,
tooltip: 'Create a new DataSet',
onClick: (dispatch) => {
const action = pushStage({
const action = setStage({
name: 'Create',
onClick: (dispatch) => {
// dialog action
Expand Down
15 changes: 12 additions & 3 deletions candis/app/client/app/reducer/DocumentProcessorReducer.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import shortid from 'shortid'
import graphlib from 'graphlib'
import cloneDeep from 'lodash.clonedeep'

import ActionType from '../constant/ActionType'
import FileFormat from '../constant/FileFormat'
Expand All @@ -16,11 +18,13 @@ const documentProcessor = (state = initialState, action) => {

if ( file.format == FileFormat.PIPELINE ) {
const data = action.payload.data
const graph = new graphlib.Graph()

const dokument =
{
ID: shortid.generate(),
output: data.output
output: data.output,
data: graph
}

const documents = state.documents.slice()
Expand All @@ -46,11 +50,16 @@ const documentProcessor = (state = initialState, action) => {
return {...state, documents: documents }
}

case ActionType.DocumentProcessor.PUSH_STAGE: {
const dokument = state.active
case ActionType.DocumentProcessor.SET_STAGE: {
const dokument = cloneDeep(state.active)

if ( dokument !== null ) {
const ID = shortid.generate()
const stage = action.payload

dokument.data.setNode(ID, stage)

return {...state, active: dokument }
}
}
}
Expand Down
85 changes: 43 additions & 42 deletions candis/app/server/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ def resource(filter_ = ['cdata', 'csv', 'cel', 'pipeline'], level = None):
def read():
response = Response()

parameters = request.get_json()
parameters = addict.Dict(request.get_json())

if 'path' in parameters:
if 'name' in parameters:
path = parameters['path']
name = parameters['name']
path = parameters.path
name = parameters.name

relpath = os.path.join(path, name)

Expand All @@ -141,49 +141,50 @@ def read():

@app.route(CONFIG.App.Routes.Api.Data.WRITE, methods = ['POST'])
def write():
response = Response()
response = Response()

parameters = addict.Dict(request.get_json())
parameters = addict.Dict(request.get_json())

if 'format' in parameters:
if 'buffer' in parameters:
format_ = parameters['format']
buffer_ = parameters['buffer']

if format_ == 'cdata':
extension = 'cdata'
prefix = 'CDAT'
writer = cdata
elif format_ == 'pipeline':
extension = 'cpipe'
prefix = 'PIPE'
writer = pipeline

if 'output' in parameters and 'name' in parameters.output:
if parameters.output.name:
name = parameters.output.name
else:
name = prefix + get_timestamp_str('%Y%m%d%H%M%S')
else:
name = prefix + get_timestamp_str('%Y%m%d%H%M%S')

fname = '{name}.{ext}'.format(name = name, ext = extension)
path = os.path.join(ABSPATH_STARTDIR, fname)
path = get_filename_if_exists(path)

try:
writer.write(path, buffer_)

path, fname = os.path.split(path)

data = addict.Dict()
data.output.path = path
data.output.name = fname

response.set_data(data)
except TypeError as e:
response.set_error(Response.Error.UNPROCESSABLE_ENTITY)
format_ = parameters.format

if 'buffer' in parameters and parameters.buffer:
buffer_ = parameters.buffer
else:
buffer_ = None

if format_ == 'cdata':
extension = 'cdata'
prefix = 'CDAT'
handler = cdata
elif format_ == 'pipeline':
extension = 'cpipe'
prefix = 'PIPE'
handler = pipeline

if 'output' in parameters and 'name' in parameters.output and parameters.output.name:
name = parameters.output.name
else:
name = prefix + get_timestamp_str('%Y%m%d%H%M%S')

fname = '{name}.{ext}'.format(name = name, ext = extension)
path = os.path.join(ABSPATH_STARTDIR, fname)
path = get_filename_if_exists(path)

try:
handler.write(path, buffer_)

data = addict.Dict()

data.data = handler.read(path)

path, fname = os.path.split(path)

data.output.path = path
data.output.name = fname

response.set_data(data)
except TypeError as e:
response.set_error(Response.Error.UNPROCESSABLE_ENTITY)
else:
response.set_error(Response.Error.UNPROCESSABLE_ENTITY)
Expand Down
2 changes: 1 addition & 1 deletion candis/ios/cdata/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_attribute_tag(attr):
return tag

def write(path, dataset, delimiter = ','):
with open(path, 'w') as f:
with open(path, mode = 'w') as f:
writer = csv.writer(f, delimiter = delimiter)
cnames = [ ]

Expand Down
7 changes: 6 additions & 1 deletion candis/ios/pipeline/reader.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# imports - module imports
from candis.util import json_load

def read(path):
pass
pipeline = json_load(path)

return pipeline
20 changes: 17 additions & 3 deletions candis/ios/pipeline/writer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
def write(path, pipeline):
with open(path, "w") as f:
pass
# imports - standard imports
import json

# imports - third-party imports
import addict

# imports - module imports
from candis.util import assign_if_none

def write(path, pipeline = None):
pipeline = assign_if_none(pipeline, addict.Dict({
'stages': [ ],
'links': [ ]
}))

with open(path, mode = 'w') as f:
json.dump(pipeline, f, indent = 4)
Binary file added docs/source/_static/img/logo-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/source/_static/img/logo.png
Binary file not shown.
12 changes: 8 additions & 4 deletions docs/source/_templates/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="wrapper">
<a href="#">
<img src="" alt="candis-logo">
<p class="logo">
<a href="{{ pathto(master_doc) }}">
<img class="logo" src="{{ pathto('_static/img/logo-title.png', 1) }}"/>
</a>
</div>
</p>

<p>
<iframe src="https://ghbtns.com/github-btn.html?user=achillesrasquinha&repo=candis&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
</p>
Loading

0 comments on commit bce308d

Please sign in to comment.