Comparar commits
27 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| d12ab2a352 | |||
| 149be7cd18 | |||
| e84a946302 | |||
| ce5f890cec | |||
| f9551b18c9 | |||
| 66b794cdbe | |||
| 89edea8c15 | |||
| a533669dd9 | |||
| c9935b52a3 | |||
| 1e2a634d5f | |||
| b755b78209 | |||
| 1ce0d70a25 | |||
| 819b541140 | |||
| 4fe4dd1bd4 | |||
| 4c876dd767 | |||
| 236c1aa93d | |||
| 73f7ba38ba | |||
| ff541be7a0 | |||
| 900ecae537 | |||
| b54b6110ef | |||
| 61fb3cad96 | |||
| 9fe83de22e | |||
| a1438e2993 | |||
| 1b7a6e56fd | |||
| 4d7a158973 | |||
| 012c9fe287 | |||
| 0b4f0145e7 |
@@ -0,0 +1 @@
|
||||
/node_modules
|
||||
@@ -35,3 +35,6 @@ test-tmp/
|
||||
blob-local-storage/
|
||||
src/seeds/nn/hash.txt
|
||||
src/seeds/pipeline/hash.txt
|
||||
|
||||
notes/
|
||||
src/worker
|
||||
|
||||
@@ -38,3 +38,6 @@ src/seeds/pipeline/hash.txt
|
||||
|
||||
# docs
|
||||
images/
|
||||
|
||||
notes/
|
||||
src/worker
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Dockerfile for running the server itself
|
||||
FROM node:6.10.1
|
||||
MAINTAINER Brian Broll <brian.broll@gmail.com>
|
||||
|
||||
RUN echo '{"allow_root": true}' > /root/.bowerrc && mkdir -p /root/.config/configstore/ && \
|
||||
echo '{}' > /root/.config/configstore/bower-github.json
|
||||
|
||||
RUN mkdir /deepforge
|
||||
ADD . /deepforge
|
||||
WORKDIR /deepforge
|
||||
|
||||
RUN cd $(npm root -g)/npm \
|
||||
&& npm install fs-extra \
|
||||
&& sed -i -e s/graceful-fs/fs-extra/ -e s/fs.rename/fs.move/ ./lib/utils/rename.js
|
||||
|
||||
RUN ln -s /deepforge/bin/deepforge /usr/local/bin
|
||||
|
||||
EXPOSE 8888
|
||||
|
||||
# Set up the data storage
|
||||
RUN deepforge config blob.dir /data/blob && \
|
||||
deepforge config mongo.dir /data/db
|
||||
|
||||
CMD ["deepforge", "start", "--server"]
|
||||
@@ -0,0 +1,65 @@
|
||||
# This has torch and cuda support
|
||||
FROM kaixhin/cuda-torch
|
||||
MAINTAINER Brian Broll <brian.broll@gmail.com>
|
||||
|
||||
# install nodejs v6
|
||||
RUN groupadd --gid 1000 node \
|
||||
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
|
||||
|
||||
# gpg keys listed at https://github.com/nodejs/node#release-team
|
||||
RUN set -ex \
|
||||
&& for key in \
|
||||
9554F04D7259F04124DE6B476D5A82AC7E37093B \
|
||||
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
|
||||
FD3A5288F042B6850C66B31F09FE44734EB7990E \
|
||||
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
|
||||
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
|
||||
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
|
||||
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
|
||||
56730D5401028683275BD23C23EFEFE93C4CFFFE \
|
||||
; do \
|
||||
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
|
||||
done
|
||||
|
||||
ENV NPM_CONFIG_LOGLEVEL info
|
||||
ENV NODE_VERSION 6.10.1
|
||||
|
||||
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
|
||||
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
||||
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
|
||||
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
||||
|
||||
# install deepforge
|
||||
RUN echo '{"allow_root": true}' > /root/.bowerrc && mkdir -p /root/.config/configstore/ && \
|
||||
echo '{}' > /root/.config/configstore/bower-github.json
|
||||
|
||||
RUN mkdir /deepforge
|
||||
ADD . /deepforge
|
||||
WORKDIR /deepforge
|
||||
|
||||
RUN cd $(npm root -g)/npm \
|
||||
&& npm install fs-extra \
|
||||
&& sed -i -e s/graceful-fs/fs-extra/ -e s/fs.rename/fs.move/ ./lib/utils/rename.js
|
||||
|
||||
RUN ln -s /deepforge/bin/deepforge /usr/local/bin
|
||||
|
||||
# configure the worker
|
||||
RUN deepforge config blob.dir /data/blob && \
|
||||
deepforge config mongo.dir /data/db && \
|
||||
deepforge config worker.cache.useBlob false && \
|
||||
deepforge config worker.cache.dir /deepforge/worker-cache && \
|
||||
deepforge config torch.dir /root/torch/ && \
|
||||
git config --global user.email "deepforge-worker@deepforge.org" && \
|
||||
git config --global user.name "deepforge-worker"
|
||||
|
||||
# Update torch
|
||||
RUN apt-get update && apt-get install sudo wget && \
|
||||
. /root/torch/install/bin/torch-activate && \
|
||||
cd /root/torch/ && bash /root/torch/update.sh && \
|
||||
deepforge update -t
|
||||
|
||||
ENTRYPOINT ["deepforge", "start", "--worker"]
|
||||
CMD ["http://172.17.0.1:8888"]
|
||||
@@ -4,6 +4,8 @@
|
||||
[](https://gitter.im/deepforge-dev/deepforge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://waffle.io/deepforge-dev/deepforge)
|
||||
|
||||
Using DeepForge? [Let us know what you think!](https://goo.gl/forms/2pDdCPXoUvkQhVzQ2)
|
||||
|
||||
# DeepForge
|
||||
DeepForge is an open-source visual development environment for deep learning providing end-to-end support for creating deep learning models. This is achieved through providing the ability to design **architectures**, create training **pipelines**, and then execute these pipelines over a cluster. Using a notebook-esque api, users can get real-time feedback about the status of any of their **executions** including compare them side-by-side in real-time.
|
||||
|
||||
@@ -19,23 +21,13 @@ Additional features include:
|
||||
- Facilitates defining custom layers
|
||||
|
||||
## Quick Start
|
||||
Simply run the following command to install deepforge with its dependencies:
|
||||
|
||||
The easiest way to start deepforge is using [docker-compose](https://docs.docker.com/compose/). Using docker-compose, deepforge can be started with
|
||||
```
|
||||
curl -o- https://raw.githubusercontent.com/dfst/deepforge/master/install.sh | bash
|
||||
wget https://raw.githubusercontent.com/deepforge-dev/deepforge/master/docker-compose.yml
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
Or, if you already have NodeJS (v6) installed, simply run
|
||||
|
||||
```
|
||||
npm install -g deepforge
|
||||
```
|
||||
|
||||
Finally, start deepforge with `deepforge start`and navigate to [http://localhost:8888](http://localhost:8888) to start using DeepForge! For more, detailed instructions, check out the [wiki](https://github.com/dfst/deepforge/wiki/Installation-Guide).
|
||||
|
||||
**Note**: running deepforge w/ `deepforge start` will also require [MongoDB](https://www.mongodb.com/download-center?jmp=nav#community) to be installed locally.
|
||||
|
||||
Also, be sure to check out the other available features of the `deepforge` cli; it can be used to update, manage your torch installation, uninstall deepforge and run individual components!
|
||||
Finally, navigate to [http://localhost:8888](http://localhost:8888) to start using DeepForge! For more detailed instructions and other installation options, check out the [docs](http://deepforge.readthedocs.io/en/latest/deployment/overview.html).
|
||||
|
||||
## Additional Resources
|
||||
- [Intro to DeepForge Slides](https://docs.google.com/presentation/d/10_y5O3gHXSATfjHVLJg7dOdrz-tAXNWjlxhJ5SlA0ic/edit?usp=sharing)
|
||||
@@ -46,7 +38,13 @@ Also, be sure to check out the other available features of the `deepforge` cli;
|
||||
- [Datamodel Developer Slides](https://docs.google.com/presentation/d/1hd3IyUlzW_TIPnzCnE-1pdz00Pw8WaIxYiOW_Hyog-M/edit#slide=id.p)
|
||||
|
||||
## Interested in contributing?
|
||||
Contributions are welcome! Either fork the project and submit some PR's or shoot me an email about getting more involved! If you have any questions, check out the [wiki](https://github.com/dfst/deepforge/wiki/) or drop me a line on the gitter!
|
||||
Contributions are welcome! There are a couple different ways to contribute to DeepForge:
|
||||
- Provide user feedback!
|
||||
- on the [documentation](http://deepforge.readthedocs.io)
|
||||
- on deepforge and its future development: https://goo.gl/forms/2pDdCPXoUvkQhVzQ2
|
||||
- Contribute to the project directly by submitting some PR's!
|
||||
|
||||
If you have any questions, check out the [wiki](https://github.com/dfst/deepforge/wiki/) or drop me a line on the gitter!
|
||||
|
||||
|
||||
Sponsored by [Digital Reasoning](http://www.digitalreasoning.com/)
|
||||
|
||||
@@ -36,7 +36,6 @@ try {
|
||||
} catch (e) {
|
||||
// Create dir
|
||||
childProcess.spawnSync('ln', ['-s', `${__dirname}/../node_modules`, modules]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check torch support
|
||||
|
||||
@@ -8,6 +8,7 @@ require('dotenv').load({silent: true});
|
||||
|
||||
// Add/overwrite any additional settings here
|
||||
config.server.port = +process.env.PORT || config.server.port;
|
||||
config.server.timeout = 0;
|
||||
config.mongo.uri = process.env.MONGO_URI || config.mongo.uri;
|
||||
config.blob.fsDir = process.env.DEEPFORGE_BLOB_DIR || config.blob.fsDir;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
services:
|
||||
mongo:
|
||||
image: mongo
|
||||
volumes:
|
||||
- "$HOME/.deepforge/data:/data/db"
|
||||
server:
|
||||
environment:
|
||||
- "MONGO_URI=mongodb://mongo:27017/deepforge"
|
||||
image: deepforge/server
|
||||
ports:
|
||||
- "8888:8888"
|
||||
volumes:
|
||||
- "$HOME/.deepforge/blob:/data/blob"
|
||||
depends_on:
|
||||
- mongo
|
||||
worker:
|
||||
command: "http://server:8888"
|
||||
image: deepforge/worker
|
||||
depends_on:
|
||||
- server
|
||||
version: "2"
|
||||
@@ -0,0 +1 @@
|
||||
_build
|
||||
@@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SPHINXPROJ = deepforge
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
@@ -0,0 +1,159 @@
|
||||
import sphinx_rtd_theme
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# deepforge documentation build configuration file, created by
|
||||
# sphinx-quickstart on Mon Mar 13 18:56:27 2017.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = 'DeepForge'
|
||||
copyright = '2017, Brian Broll'
|
||||
author = 'Brian Broll'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = ''
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = ''
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'deepforgedoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'deepforge.tex', 'deepforge Documentation',
|
||||
'Brian Broll', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'deepforge', 'deepforge Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'deepforge', 'deepforge Documentation',
|
||||
author, 'deepforge', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
Dockerized Installation
|
||||
-----------------------
|
||||
Each of the components are also available as docker containers. This page outlines the running of each of the main components as docker containers and connecting them as necessary.
|
||||
|
||||
Database
|
||||
~~~~~~~~
|
||||
First, you can start the mongo container using:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker run -d -v /abs/path/to/data:/data/db mongo
|
||||
|
||||
where :code:`/abs/path/to/data` is the path to the mongo data location on the host. If running the database in a container, you will need to get the ip address of the given container:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker inspect <container id> | grep IPAddr
|
||||
|
||||
The :code:`<container id>` is the value returned from the original :code:`docker run` command.
|
||||
|
||||
When running mongo in a docker container, it is important to mount an external volume (using the :code:`-v` flag) to be used for the actual data (otherwise the data will be lost when the container is stopped).
|
||||
|
||||
Server
|
||||
~~~~~~
|
||||
The DeepForge server can be started with
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker run -d -v $HOME/.deepforge/blob:/data/blob \
|
||||
-p 8888:8888 -e MONGO_URI=mongodb://172.17.0.2:27017/deepforge \
|
||||
deepforge/server
|
||||
|
||||
where :code:`172.17.0.2` is the ip address of the mongo container and :code:`$HOME/.deepforge/blob` is the path to use for binary DeepForge data on the host. Of course, if the mongo instance is locating at a different location, :code:`MONGO_URI` can be set to this address as well. Also, the first port (:code:`8888`) can be replaced with the desired port to expose on the host.
|
||||
|
||||
Worker
|
||||
~~~~~~
|
||||
As workers may require GPU access, they will need to use the nvidia-docker plugin. Workers can be created using
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
nvidia-docker run -d deepforge/worker http://172.17.0.1:8888
|
||||
|
||||
where :code:`http://172.17.0.1:8888` is the location of the DeepForge server to which to connect.
|
||||
|
||||
**Note**: The :code:`deepforge/worker` image is packaged with cuda 7.5. Depending upon your hardware and nvidia version, you may need to build your own docker image or run the worker natively.
|
||||
@@ -0,0 +1,130 @@
|
||||
Native Installation
|
||||
===================
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
First, install `NodeJS <https://nodejs.org/en/>`_ (v6) and `MongoDB <https://www.mongodb.org/>`_. You may also need to install git if you haven't already.
|
||||
|
||||
Next, you can install DeepForge using npm:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
npm install -g deepforge
|
||||
|
||||
Now, you can check that it installed correctly:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge --version
|
||||
|
||||
DeepForge can now be started with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start
|
||||
|
||||
However, the first time DeepForge is started, it will make sure that the deep learning framework is installed (if it isn't found on the host system). This may require you to start DeepForge a couple times; the first time it starts it will install Torch7 and require a terminal restart to update a couple environment variables (like `PATH`). The second time it starts it will install additional torch packages but will not require a terminal restart. Finally, DeepForge will start with all the required dependencies.
|
||||
|
||||
Database
|
||||
~~~~~~~~
|
||||
Download and install MongoDB from the `website <https://www.mongodb.org/>`_. If you are planning on running MongoDB locally on the same machine as DeepForge, simply start `mongod` and continue to setting up DeepForge.
|
||||
|
||||
If you are planning on running MongoDB remotely, set the environment variable "MONGO_URI" to the URI of the Mongo instance that DeepForge will be using:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
MONGO_URI="mongodb://pathToMyMongo.com:27017/myCollection" deepforge start
|
||||
|
||||
Server
|
||||
~~~~~~
|
||||
The DeepForge server is included with the deepforge cli and can be started simply with
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start --server
|
||||
|
||||
By default, DeepForge will start on `http://localhost:8888`. However, the port can be specified with the `--port` option. For example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start --server --port 3000
|
||||
|
||||
Worker
|
||||
~~~~~~
|
||||
The DeepForge worker can be started with
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start --worker
|
||||
|
||||
The worker will install dependencies the first time it is run (including torch, if it is not already installed).
|
||||
|
||||
To connect to a remote deepforge instance, add the url of the DeepForge server:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start --worker http://myaddress.com:1234
|
||||
|
||||
Updating
|
||||
~~~~~~~~
|
||||
DeepForge can be updated with the command line interface rather simply:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge update
|
||||
|
||||
By default, this will update both DeepForge and the local torch installation. To only update DeepForge, add the `--server` flag:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge update --server
|
||||
|
||||
For more update options, check out `deepforge update --help`!
|
||||
|
||||
Manual Installation (Development)
|
||||
---------------------------------
|
||||
Installing DeepForge for development is essentially cloning the repository and then using `npm` (node package manager) to run the various start, test, etc, commands (including starting the individual components). The deepforge cli can still be used but must be referenced from `./bin/deepforge`. That is, `deepforge start` becomes `./bin/deepforge start` (from the project root).
|
||||
|
||||
DeepForge Server
|
||||
~~~~~~~~~~~~~~~~
|
||||
First, clone the repository:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/dfst/deepforge.git
|
||||
|
||||
Then install the project dependencies:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
npm install
|
||||
|
||||
To run all components locally start with
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./bin/deepforge start
|
||||
|
||||
and navigate to `http://localhost:8888` to start using DeepForge!
|
||||
|
||||
Alternatively, if jobs are going to be executed on an external worker, run `./bin/deepforge start -s` locally and navigate to `http://localhost:8888`.
|
||||
|
||||
DeepForge Worker
|
||||
~~~~~~~~~~~~~~~~
|
||||
If you are using `./bin/deepforge start -s` you will need to set up a DeepForge worker (`./bin/deepforge start` starts a local worker for you!). DeepForge workers are slave machines connected to DeepForge which execute the provided jobs. This allows the jobs to access the GPU, etc, and provides a number of benefits over trying to perform deep learning tasks in the browser.
|
||||
|
||||
Once DeepForge is installed on the worker, start it with
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./bin/deepforge start -w
|
||||
|
||||
Note: If you are running the worker on a different machine, put the address of the DeepForge server as an argument to the command. For example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./bin/deepforge start -w http://myaddress.com:1234
|
||||
|
||||
Updating
|
||||
~~~~~~~~
|
||||
Updating can be done the same as any other git project; that is, by running `git pull` from the project root. Sometimes, the dependencies need to be updated so it is recommended to run `npm install` following `git pull`.
|
||||
@@ -0,0 +1,26 @@
|
||||
Overview
|
||||
========
|
||||
|
||||
DeepForge Component Overview
|
||||
----------------------------
|
||||
DeepForge is composed of four main elements:
|
||||
|
||||
- *Server*: Main component hosting all the project information and is connected to by the clients
|
||||
- *Database*: MongoDB database containing DeepForge, job queue for the workers, etc
|
||||
- *Worker*: Slave machine performing the actual machine learning computation
|
||||
- *Client*: The connected browsers working on DeepForge projects.
|
||||
|
||||
Of course, only the *Server*, *Database* (MongoDB) and *Worker* need to be installed. If you are not going to execute any machine learning pipelines, installing the *Worker* can be skipped.
|
||||
|
||||
Component Dependencies
|
||||
----------------------
|
||||
The following dependencies are required for each component:
|
||||
|
||||
- *Server* (NodeJS v6.2.1)
|
||||
- *Database* (MongoDB v3.0.7)
|
||||
- *Worker*: NodeJS v6.2.1 (used for job management logic) and `Torch <http://torch.ch/docs/getting-started.html#>`_ (this will be installed automatically by the cli when needed)
|
||||
- *Client*: We recommend using Google Chrome and are not supporting other browsers (for now). In other words, other browsers can be used at your own risk.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
After installing DeepForge, it can be helpful to check out `configuring DeepForge <getting_started/configuration.rst>`_
|
||||
|
Depois Largura: | Altura: | Tamanho: 37 KiB |
@@ -0,0 +1,13 @@
|
||||
Custom Data Types
|
||||
=================
|
||||
|
||||
As operation inputs and outputs are strongly typed, DeepForge supports the creation of custom data types to promote flexibility when designing complex pipelines and operations. DeepForge data types can be either primitive types or custom classes. Custom DeepForge primitive types are relatively straight-forward; they can inherit from other types and must implement a serialization and deserialization methods (which may be as simple as :code:`torch.save` and :code:`torch.load`). Custom classes are also relatively simple to define but actually contain their own methods along with serialization and deserialization functions.
|
||||
|
||||
New data types can be defined from the operation editor from the dialog for selecting input or output data for the operation. After defining a new class, this class is available from within any of the operations in the DeepForge project.
|
||||
|
||||
.. figure:: model_data_editor.png
|
||||
:align: center
|
||||
:scale: 55 %
|
||||
|
||||
Editing the serialization and deserialization for the "model" type
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
Custom Layers
|
||||
=============
|
||||
|
||||
DeepForge supports the creation of custom neural network layers using Torch7 and the easy usage of these layers in the visual architecture editor. Before creating custom layers, it is recommended to read about `creating custom layers in Torch7 <http://torch.ch/docs/developer-docs.html>`_.
|
||||
|
||||
A new custom layer can be created from the "add layer dialog" in the architecture editor. When creating a layer, DeepForge provides a code editor for creating custom neural network layers prepopulated with a basic template for defining the custom layer.
|
||||
|
||||
After defining the layer in the layer editor, DeepForge will provide this layer in the architecture editor and expose any configurable attributes for the layer. These attributes are parsed from the layer definition.
|
||||
|
||||
Best Practices
|
||||
--------------
|
||||
Here are a couple best practices to keep in mind when defining custom neural network layers:
|
||||
|
||||
- Use type assertions for layer, boolean attributes
|
||||
|
||||
- Return :code:`self` when defining setter functions
|
||||
|
||||
**Type assertions** should be used when defining layer attributes (ie, constructor arguments or arguments to a setter function). For example, consider the following layer definition for :code:`RecurrentAttention` which accepts an :code:`action` layer argument to its constructor.
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
local RecurrentAttention, parent = torch.class("nn.RecurrentAttention", "nn.AbstractSequencer")
|
||||
|
||||
function RecurrentAttention:__init(rnn, action, nStep, hiddenSize)
|
||||
parent.__init(self)
|
||||
assert(torch.isTypeOf(action, 'nn.Module'))
|
||||
assert(torch.type(nStep) == 'number')
|
||||
assert(torch.type(hiddenSize) == 'table')
|
||||
assert(torch.type(hiddenSize[1]) == 'number', "Does not support table hidden layers" )
|
||||
|
||||
self.rnn = rnn
|
||||
-- we can decorate the module with a Recursor to make it AbstractRecurrent
|
||||
self.rnn = (not torch.isTypeOf(rnn, 'nn.AbstractRecurrent')) and nn.Recursor(rnn) or rnn
|
||||
|
||||
-- samples an x,y actions for each example
|
||||
self.action = (not torch.isTypeOf(action, 'nn.AbstractRecurrent')) and nn.Recursor(action) or action
|
||||
self.hiddenSize = hiddenSize
|
||||
self.nStep = nStep
|
||||
|
||||
self.modules = {self.rnn, self.action}
|
||||
|
||||
self.output = {} -- rnn output
|
||||
self.actions = {} -- action output
|
||||
|
||||
self.forwardActions = false
|
||||
|
||||
self.gradHidden = {}
|
||||
end
|
||||
|
||||
In this example, :code:`assert(torch.isTypeOf(action, 'nn.Module'))` enforces that the :code:`action` variable is another neural network layer. After defining the layer, DeepForge will parse the layer definition and create a visual representation for use in the architecture editor. As this assertion enforces that :code:`action` is a neural network layer, DeepForge will update itself accordingly; in this case, editing the attribute will allow the user to hierarchically create nested neural network architectures to be passed as the :code:`action` argument to the constructor.
|
||||
|
||||
.. figure:: recurrent_attention.png
|
||||
:align: center
|
||||
:scale: 85 %
|
||||
|
||||
RecurrentAttention has attributes for each of the constructor arguments
|
||||
|
||||
An example of the generated visual model for the :code:`RecurrentAttention` is provided above. This layer has attributes for each of the constructor arguments defined in its definition. Clicking on the :code:`<none>` value for the :code:`action` attribute will then allow the user to provide layer inputs as shown below.
|
||||
|
||||
.. figure:: action_layer.png
|
||||
:align: center
|
||||
:scale: 55 %
|
||||
|
||||
Creating layer inputs for the "action" variable
|
||||
|
||||
The second best practice is to make sure to **return self in any setter functions**. An example of this can be found in the setters in the :code:`SpatialMaxPooling` layer shown below:
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
function SpatialMaxPooling:ceil()
|
||||
self.ceil_mode = true
|
||||
return self
|
||||
end
|
||||
|
||||
function SpatialMaxPooling:floor()
|
||||
self.ceil_mode = false
|
||||
return self
|
||||
end
|
||||
|
||||
Returning :code:`self` in setter functions is a good convention when defining neural network layers in Torch7 as it promotes simple and legible code such as
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
net:add(nn.SpatialMaxPooling(5, 5, 2, 2):ceil())
|
||||
|
||||
where :code:`net` is a container like a :code:`Sequential` layer. DeepForge enforces this convention and, if it finds a setter function (which also returns :code:`self`) in the layer definition will expose the internal variable (in this case :code:`ceil_mode`) to the user in the visual editor.
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
Custom Operations
|
||||
=================
|
||||
|
||||
In this document we will outline the basics of custom operations including the operation editor and operation feedback utilities.
|
||||
|
||||
The Basics
|
||||
----------
|
||||
Operations are used in pipelines and have named, typed inputs and outputs. When creating a pipeline, if you don't currently find an operation for the given task, you can easily create your own by selecting the `New Operation...` operation from the add operation dialog. This will create a new operation definition and open it in the operation editor. The operation editor has two main parts, the interface editor and the implementation editor.
|
||||
|
||||
.. figure:: operation_editor.png
|
||||
:align: center
|
||||
:scale: 45 %
|
||||
|
||||
Editing the "train" operation provided in the "First Steps" section
|
||||
|
||||
The interface editor is provided on the left and presents the interface as a diagram showing the input data and output data as objects flowing into or out of the given operation. Selecting the operation node in the operation interface editor will expand the node and allow the user to add or edit attributes for the given operation. These attributes are exposed when using this operation in a pipeline and can be set at design time - that is, these are set when creating the given pipeline. The interface diagram may also contain light blue nodes flowing into the operation. These nodes represent "references" that the operation accepts as input before running. When using the operation, references will appear alongside the attributes but will allow the user to select from a list of all possible targets when clicked.
|
||||
|
||||
.. figure:: operation_interface.png
|
||||
:align: center
|
||||
:scale: 85 %
|
||||
|
||||
The train operation accepts training data, an architecture and criterion and returns a trained model
|
||||
|
||||
On the right of the operation editor is the implementation editor. The implementation editor is a code editor specially tailored for programming the implementations of operations in DeepForge. This includes some autocomplete support for common globals in this context like the :code:`deepforge` and :code:`torch` globals. It also is synchronized with the interface editor and will provide input to the interface editor about unused variables, etc. These errors will present themselves as error or warning highlights on the data in the interface editor. A section of the implementation is shown below:
|
||||
|
||||
.. code:: lua
|
||||
|
||||
trainer = nn.StochasticGradient(net, criterion)
|
||||
trainer.learningRate = attributes.learningRate
|
||||
trainer.maxIteration = attributes.maxIterations
|
||||
|
||||
print('training for ' .. tostring(attributes.maxIterations) .. ' iterations (max)')
|
||||
print('learning rate is ' .. tostring(attributes.learningRate))
|
||||
print(trainer)
|
||||
|
||||
-- Adding the error graph
|
||||
graph = deepforge.Graph('Training Error') -- creating graph feedback
|
||||
errLine = graph:line('error')
|
||||
trainer.hookIteration = function(t, iter, currentErr)
|
||||
errLine:add(iter, currentErr) -- reporting the current error (will update in real time in DeepForge)
|
||||
end
|
||||
|
||||
trainer:train(trainset)
|
||||
|
||||
return {
|
||||
net = net
|
||||
}
|
||||
|
||||
The "train" operation uses the :code:`StochasticGradient` functionality from the :code:`nn` package to perform stochastic gradient descent. This operation sets all the parameters using values provided to the operation as either attributes or references. In the implementation, attributes are provided by the :code:`attributes` variable and provides access to the user defined attributes from within the implementation. References are treated similarly to operation inputs and are defined in variables of the same name. This can be seen with the :code:`net` and :code:`criterion` variables in the first line. Finally, operations return a table of their named outputs; in this example, it returns a single output named :code:`net`, that is, the trained neural network.
|
||||
|
||||
After defining the interface and implementation, we can now use the "train" operation in our pipelines! An example is shown below.
|
||||
|
||||
.. figure:: train_operation.png
|
||||
:align: center
|
||||
:scale: 85 %
|
||||
|
||||
Using the custom "train" operation in a pipeline
|
||||
|
||||
Operation feedback
|
||||
------------------
|
||||
Operations in DeepForge can generate metadata about its execution. This metadata is generated during the execution and provided back to the user in real-time. An example of this includes providing real-time plotting feedback of the loss function of a model while training. When implementing an operation in DeepForge, this metadata can be created using the :code:`deepforge` global.
|
||||
|
||||
.. figure:: graph_example.png
|
||||
:align: center
|
||||
:scale: 75 %
|
||||
|
||||
An example graph of the loss function while training a neural network
|
||||
|
||||
Detailed information about the available operation metadata types can be found in the `reference <reference/feedback_mechanisms.rst>`_.
|
||||
|
Depois Largura: | Altura: | Tamanho: 39 KiB |
|
Depois Largura: | Altura: | Tamanho: 51 KiB |
|
Depois Largura: | Altura: | Tamanho: 108 KiB |
|
Depois Largura: | Altura: | Tamanho: 16 KiB |
|
Depois Largura: | Altura: | Tamanho: 8.8 KiB |
|
Depois Largura: | Altura: | Tamanho: 12 KiB |
|
Depois Largura: | Altura: | Tamanho: 35 KiB |
@@ -0,0 +1,32 @@
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
.. _Torch: http://torch.ch
|
||||
|
||||
What is DeepForge?
|
||||
------------------
|
||||
Deep learning is a very promising, yet complex, area of machine learning. This complexity can both create a barrier to entry for those wanting to get involved in deep learning as well as slow the development of those already comfortable in deep learning.
|
||||
|
||||
DeepForge is a development environment for deep learning focused on alleviating these problems. Leveraging the flexibility of Torch_, DeepForge is able to reduce the complexity of using deep learning while still providing advanced features such as defining custom layers.
|
||||
|
||||
Design Goals
|
||||
------------
|
||||
As mentioned above, DeepForge focuses on two main goals:
|
||||
|
||||
1. **Improving the efficiency** of experienced data scientists/researchers in deep learning
|
||||
2. **Lowering the barrier to entry** for newcomers to deep learning
|
||||
|
||||
It is important to highlight that although one of the goals is focused on lowering the barrier to entry, DeepForge is intended to be more than simply an educational tool; that is, it is important not to compromise on flexibility and effectiveness as a research/industry tool in order to provide an easier experience for beginners (that's what forks are for!).
|
||||
|
||||
Overview and Features
|
||||
---------------------
|
||||
DeepForge provides a collaborative, distributed development environment for deep learning. The development environment is a hybrid visual and textual programming environment. Higher levels of abstraction, such as creating architectures, use visual environments to capture the overall structure of the task while lower levels of abstraction, such as defining custom layers, utilize text environments to maintain the flexibility provided by torch.
|
||||
|
||||
Concepts and Terminology
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
- *Architecture* - neural network architecture composed of torch defined layers
|
||||
- *Operation* - essentially a function written in torch (such as `SGD`)
|
||||
- *Pipeline* - directed acyclic graph composed of operations
|
||||
- eg, a training pipeline may retrieve and normalize data, train an architecture and return the trained model
|
||||
- *Execution* - when a pipeline is run, an "execution" is created and reports the status of each operation as it is run (distributed over a number of worker machines)
|
||||
- *Artifact* - an artifact represents some data (either user uploaded or created during an execution)
|
||||
@@ -0,0 +1,63 @@
|
||||
First Steps
|
||||
===========
|
||||
DeepForge provides an example project for creating a classifier using the `CIFAR10 <https://www.kaggle.com/c/cifar-10>`_ dataset.
|
||||
|
||||
When first opening DeepForge in your browser (at `http://localhost:8888` if following the instructions from the `quick start <getting_started/installation.rst>`_), you will be prompted with a list of projects to open and provided the option to create a new project. For this example, let's click "Create new..." and name our project "hello_cifar".
|
||||
|
||||
.. figure:: create_project.png
|
||||
:align: center
|
||||
:scale: 65 %
|
||||
|
||||
Creating our "hello_cifar" example project
|
||||
|
||||
Clicking "Create" will bring us to a prompt for the "seed" for our project. Select "cifar10" from the dropdown and click "Create". This will now create our new project based on the cifar10 example provided with DeepForge.
|
||||
|
||||
.. figure:: set_seed.png
|
||||
:align: center
|
||||
:scale: 75 %
|
||||
|
||||
Selecting the "cifar10" example seed
|
||||
|
||||
In this example, we have three main pipelines: :code:`download-normalize`, :code:`train` and :code:`test`. :code:`download-normalize` downloads and prepares our data. The :code:`train` pipeline trains a neural network model on the cifar10 dataset and the :code:`test` pipeline tests our trained model on our test set from the cifar10 dataset.
|
||||
|
||||
.. figure:: pipelines.png
|
||||
:align: center
|
||||
:scale: 65 %
|
||||
|
||||
Three main pipelines in the cifar10 example project
|
||||
|
||||
First, we will have to retrieve and prepare the data by running the :code:`download-normalize` pipeline. This can be done by opening the given pipeline then selecting the `Execute Pipeline` option from the action button in the lower right. As soon as that pipeline finishes, we can now use this data to train a neural network.
|
||||
|
||||
Next, we can open the :code:`train` pipeline. Before we execute the pipeline we have to set the input training data that we will be using. This is done by selecting the :code:`Input` operation then clicking the value for the :code:`artifact` field. This will provide all the possible options for the input data; for this example, we will want to select the "trainingdata" artifact. After setting the input, we can click on the :code:`train` operation to inspect the hyperparameters we are using and the architecture we are training. Selecting the :code:`Output` operation will allow you to change the name of the resulting artifact of this operation (in this case, a trained model). Finally, we can execute this pipeline like before to train the model.
|
||||
|
||||
.. figure:: select_train_data.png
|
||||
:align: center
|
||||
:scale: 65 %
|
||||
|
||||
Selecting the training data for the input to the training pipeline
|
||||
|
||||
As this operation trains, we can view the status by viewing the running execution. The easiest way to view the running execution is by clicking the given execution from the execution tray in the bottom left when viewing the originating pipeline.
|
||||
|
||||
.. figure:: training_execution.png
|
||||
:align: center
|
||||
:scale: 65 %
|
||||
|
||||
Viewing the execution of the training pipeline
|
||||
|
||||
Once the model has been trained, we can test the given model using the :code:`test` pipeline. In this pipeline, we have a few more inputs to set: "testing data", "model to test" and the "human-readable class labels". If you aren't clear which operation provides which input, you can simply hover over it's connected port on the :code:`test` operation. This will provide a tooltip with the full name of the input.
|
||||
|
||||
.. figure:: test_pipeline.png
|
||||
:align: center
|
||||
:scale: 65 %
|
||||
|
||||
Viewing the execution of the testing pipeline
|
||||
|
||||
After setting the inputs for the :code:`test` pipeline (using the trained model and data from the first two pipelines), we can simply execute this pipeline to test our model. After executing the :code:`test` pipeline, we can view the execution and open the :code:`test` job to view the stdout for the given job. In the :code:`test` operation, this will allow us to view the printed accuracies of the model over each class.
|
||||
|
||||
.. figure:: test_results.png
|
||||
:align: center
|
||||
:scale: 65 %
|
||||
|
||||
Viewing the results of the testing operation
|
||||
|
||||
And that's it! We have just trained and tested our first neural network model using DeepForge. Although there are still a lot more advanced features that can be used, this should at least familiarize us with some of the core concepts in DeepForge.
|
||||
|
Depois Largura: | Altura: | Tamanho: 47 KiB |
@@ -0,0 +1,19 @@
|
||||
Quick Start
|
||||
===========
|
||||
The easiest way to get started quickly with DeepForge is using docker-compose. First, install `docker <https://docs.docker.com/engine/installation/>`_ and `docker-compose <https://docs.docker.com/compose/install/>`_.
|
||||
|
||||
Next, download the docker-compose file for DeepForge:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
wget https://raw.githubusercontent.com/deepforge-dev/deepforge/master/docker-compose.yml
|
||||
|
||||
Then start DeepForge using docker-compose:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose up
|
||||
|
||||
and now DeepForge can be used by opening a browser to `http://localhost:8888 <http://localhost:8888>`_!
|
||||
|
||||
For detailed instructions about deployment installations, check out our `deployment installation instructions <getting_started/configuration.rst>`_
|
||||
|
Depois Largura: | Altura: | Tamanho: 6.7 KiB |
|
Depois Largura: | Altura: | Tamanho: 17 KiB |
|
Depois Largura: | Altura: | Tamanho: 44 KiB |
|
Depois Largura: | Altura: | Tamanho: 55 KiB |
|
Depois Largura: | Altura: | Tamanho: 46 KiB |
@@ -0,0 +1,40 @@
|
||||
.. DeepForge documentation master file, created by
|
||||
sphinx-quickstart on Mon Mar 13 18:56:27 2017.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to DeepForge's documentation!
|
||||
=====================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Getting Started
|
||||
|
||||
getting_started/getting_started.rst
|
||||
getting_started/quick_start.rst
|
||||
getting_started/hello_cifar.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Fundamentals
|
||||
|
||||
fundamentals/custom_operations.rst
|
||||
fundamentals/custom_layers.rst
|
||||
fundamentals/custom_data_types.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Deployment
|
||||
|
||||
deployment/overview.rst
|
||||
deployment/native.rst
|
||||
deployment/dockerized.rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Reference
|
||||
|
||||
reference/cli.rst
|
||||
reference/configuration.rst
|
||||
reference/operation_feedback.rst
|
||||
reference/extensions.rst
|
||||
@@ -0,0 +1,91 @@
|
||||
Command Line Interface
|
||||
======================
|
||||
|
||||
This document outlines the functionality of the deepforge command line interface (provided after installing deepforge with :code:`npm install -g deepforge`).
|
||||
|
||||
- Installation Configuration
|
||||
- Starting DeepForge or Components
|
||||
- Installing and Upgrading Torch
|
||||
- Update or Uninstall DeepForge
|
||||
- Managing Extensions
|
||||
|
||||
Installation Configuration
|
||||
--------------------------
|
||||
Installation configuration including the installation location of Torch7 and data storage locations. These can be edited using the :code:`deepforge config` command as shown in the following examples:
|
||||
|
||||
Printing all the configuration settings:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge config
|
||||
|
||||
|
||||
Printing the value of a configuration setting:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge config torch.dir
|
||||
|
||||
|
||||
Setting a configuration option, such as :code:`torch.dir` can be done with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge config torch.dir /some/new/directory
|
||||
|
||||
|
||||
For more information about the configuration settings, check out the `configuration <configuration.rst>`_ page.
|
||||
|
||||
|
||||
Starting DeepForge Components
|
||||
-----------------------------
|
||||
DeepForge components, such as the server or the workers, can be started with the :code:`deepforge start` command. By default, this command will start all the necessary components to run including the server, a mongo database (if applicable) and a worker.
|
||||
|
||||
The server can be started by itself using
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start --server
|
||||
|
||||
|
||||
The worker can be started by itself using
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge start --worker http://154.95.87.1:7543
|
||||
|
||||
|
||||
where `http://154.95.87.1:7543` is the url of the deepforge server.
|
||||
|
||||
Installing and Upgrading Torch7
|
||||
-------------------------------
|
||||
Torch7 is lazily installed when starting a worker (if torch isn't already installed) with the rnn package. This installation can be manually updated as described in the update and installation section.
|
||||
|
||||
Update/Uninstall DeepForge
|
||||
--------------------------
|
||||
DeepForge can be updated or uninstalled using
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge update
|
||||
|
||||
|
||||
The torch installation can be updated using
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge update --torch
|
||||
|
||||
|
||||
DeepForge can be uninstalled using :code:`deepforge uninstall`
|
||||
|
||||
Managing Extensions
|
||||
-------------------
|
||||
DeepForge extensions can be installed and removed using the :code:`deepforge extensions` subcommand. Extensions can be added, removed and listed as shown below
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge extensions add https://github.com/example/some-extension
|
||||
deepforge extensions remove some-extension
|
||||
deepforge extensions list
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Configuration of deepforge is done through the `deepforge config` command from the command line interface. To see all config options, simply run `deepforge config` with no additional arguments. This will print a JSON representation of the configuration settings similar to:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
Current config:
|
||||
{
|
||||
"torch": {
|
||||
"dir": "/home/irishninja/.deepforge/torch"
|
||||
},
|
||||
"blob": {
|
||||
"dir": "/home/irishninja/.deepforge/blob"
|
||||
},
|
||||
"worker": {
|
||||
"cache": {
|
||||
"useBlob": true,
|
||||
"dir": "~/.deepforge/worker/cache"
|
||||
},
|
||||
"dir": "~/.deepforge/worker"
|
||||
},
|
||||
"mongo": {
|
||||
"dir": "~/.deepforge/data"
|
||||
}
|
||||
}
|
||||
|
||||
Setting an attribute, say `worker.cache.dir`, is done as follows
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
deepforge config worker.cache.dir /tmp
|
||||
|
||||
Environment Variables
|
||||
---------------------
|
||||
Most settings have a corresponding environment variable which can be used to override the value set in the cli's configuration. This allows the values to be temporarily set for a single run. For example, starting a worker with a different cache than set in `worker.cache.dir` can be done with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
DEEPFORGE_WORKER_CACHE=/tmp deepforge start -w
|
||||
|
||||
The complete list of the environment variable overrides for the configuration options can be found `here <https://github.com/deepforge-dev/deepforge/blob/master/bin/envConfig.json>`_.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
torch.dir
|
||||
~~~~~~~~~
|
||||
The path to the local installation of torch to be used by the deepforge worker. This is used when installing, upgrading and removing the local torch installation
|
||||
|
||||
blob.dir
|
||||
~~~~~~~~
|
||||
The path to the blob (large file storage containing models, datasets, etc) to be used by the deepforge server.
|
||||
|
||||
This can be overridden with the `DEEPFORGE_BLOB_DIR` environment variable.
|
||||
|
||||
worker.dir
|
||||
~~~~~~~~~~
|
||||
The path to the directory used for worker executions. The workers will run the executions from this directory.
|
||||
|
||||
This can be overridden with the `DEEPFORGE_WORKER_DIR` environment variable.
|
||||
|
||||
mongo.dir
|
||||
~~~~~~~~~
|
||||
The path to use for the `--dbpath` option of mongo if starting mongo using the command line interface. That is, if the MONGO_URI is set to a local uri and the cli is starting the deepforge server, the cli will check to verify that an instance of mongo is running locally. If not, it will start it on the given port and use this setting for the `--dbpath` setting of mongod.
|
||||
|
||||
worker.cache.dir
|
||||
~~~~~~~~~~~~~~~~
|
||||
The path to the worker cache directory.
|
||||
|
||||
This can be overridden with the `DEEPFORGE_WORKER_CACHE` environment variable.
|
||||
|
||||
worker.cache.useBlob
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
When running the worker on the same machine as the server, this allows the worker to use the blob as a cache and simply create symbolic links to the data (eg, training data, models) to prevent having to even perform a copy of the data on the given machine.
|
||||
|
||||
This can be overridden with the `DEEPFORGE_WORKER_USE_BLOB` environment variable.
|
||||
@@ -0,0 +1,53 @@
|
||||
Operation Feedback
|
||||
==================
|
||||
|
||||
DeepForge provides the `deepforge` global object in operation implementations for providing feedback during the execution. The various types of metadata are provided and discussed below.
|
||||
|
||||
Graphs
|
||||
------
|
||||
Real-time graphs can be created using the graph constructor:
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
local graph = deepforge.Graph('My Graph') -- created a new graph called "My Graph"
|
||||
|
||||
After creating a graph, lines can be added similarly.
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
local line1 = graph:line('first line') -- created a new line called "first line"
|
||||
local line2 = graph:line('second line') -- created a second line called "second line"
|
||||
|
||||
Finally, points can be added to the lines by calling the `:add` method on the line and passing the x and y values for the given point.
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
line1:add(1, 3) -- adding point (1, 3) to line1
|
||||
line2:add(1, 4) -- adding point (1, 4) to line2
|
||||
|
||||
line1:add(2, 5) -- adding point (2, 5) to line1
|
||||
line2:add(2, 6) -- adding point (2, 6) to line2
|
||||
|
||||
Graphs can then label their axis as follows:
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
graph:xlabel('x axis') -- label the x axis "x axis"
|
||||
graph:ylabel('y axis') -- label the y axis "y axis"
|
||||
|
||||
|
||||
Images
|
||||
------
|
||||
Images can be created using:
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
local image = deepforge.Image('My Example Image', imageTensor)
|
||||
|
||||
The first argument is the title of the image and the second argument is the tensor for the image (optional). Both the title and the tensor can be updated during execution as follows.
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
image:title('My New Title') -- updating the image title
|
||||
image:update(newTensor) -- updating the displayed image
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "deepforge",
|
||||
"version": "1.1.0",
|
||||
"version": "1.3.0",
|
||||
"dependencies": {
|
||||
"abbrev": {
|
||||
"version": "1.1.0",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"watch-test": "nodemon --exec 'mocha --recursive test'",
|
||||
"build-nn": "node ./utils/nn-parser.js"
|
||||
},
|
||||
"version": "1.2.0",
|
||||
"version": "1.4.1",
|
||||
"dependencies": {
|
||||
"commander": "^2.9.0",
|
||||
"dotenv": "^2.0.0",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*globals define */
|
||||
// This is a mixin containing helpers for working with operation nodes
|
||||
define([],function() {
|
||||
|
||||
var OperationOps = function() {
|
||||
};
|
||||
|
||||
OperationOps.prototype.getOutputs = function (node) {
|
||||
return this.getOperationData(node, this.META.Outputs);
|
||||
};
|
||||
|
||||
OperationOps.prototype.getInputs = function (node) {
|
||||
return this.getOperationData(node, this.META.Inputs);
|
||||
};
|
||||
|
||||
OperationOps.prototype.getOperationData = function (node, metaType) {
|
||||
// Load the children and the output's children
|
||||
return this.core.loadChildren(node)
|
||||
.then(containers => {
|
||||
var outputs = containers.find(c => this.core.isTypeOf(c, metaType));
|
||||
return outputs ? this.core.loadChildren(outputs) : [];
|
||||
})
|
||||
.then(outputs => {
|
||||
var bases = outputs.map(node => this.core.getMetaType(node));
|
||||
// return [[arg1, Type1, node1], [arg2, Type2, node2]]
|
||||
return outputs.map((node, i) => [
|
||||
this.getAttribute(node, 'name'),
|
||||
this.getAttribute(bases[i], 'name'),
|
||||
node
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
return OperationOps;
|
||||
});
|
||||
@@ -6,27 +6,64 @@ define([
|
||||
PluginUtils,
|
||||
Q
|
||||
) {
|
||||
|
||||
var CodeGen = {
|
||||
Operation: {
|
||||
pluginId: 'GenerateJob',
|
||||
namespace: 'pipeline'
|
||||
}
|
||||
};
|
||||
|
||||
var PtrCodeGen = function() {
|
||||
};
|
||||
|
||||
PtrCodeGen.prototype.getCodeGenPluginIdFor = function(node) {
|
||||
var base = this.core.getBase(node),
|
||||
name = this.core.getAttribute(node, 'name'),
|
||||
namespace = this.core.getNamespace(node),
|
||||
pluginId;
|
||||
|
||||
//this.logger.debug(`loaded pointer target of ${ptrId}: ${ptrNode}`);
|
||||
pluginId = (this.core.getOwnRegistry(node, 'validPlugins') || '').split(' ').shift();
|
||||
//this.logger.info(`generating code for ${this.core.getAttribute(ptrNode, 'name')} using ${pluginId}`);
|
||||
|
||||
if (this.core.isMetaNode(node) && CodeGen[name]) {
|
||||
pluginId = CodeGen[name].pluginId || CodeGen[name];
|
||||
namespace = CodeGen[name].namespace;
|
||||
}
|
||||
|
||||
if (pluginId) {
|
||||
return {
|
||||
namespace: namespace,
|
||||
pluginId: pluginId
|
||||
};
|
||||
} else if (base) {
|
||||
return this.getCodeGenPluginIdFor(base);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
PtrCodeGen.prototype.getPtrCodeHash = function(ptrId) {
|
||||
return this.core.loadByPath(this.rootNode, ptrId)
|
||||
.then(ptrNode => {
|
||||
// Look up the plugin to use
|
||||
var metanode = this.core.getMetaType(ptrNode),
|
||||
pluginId;
|
||||
var genInfo = this.getCodeGenPluginIdFor(ptrNode);
|
||||
|
||||
this.logger.debug(`loaded pointer target of ${ptrId}: ${ptrNode}`);
|
||||
pluginId = this.core.getRegistry(ptrNode, 'validPlugins').split(' ').shift();
|
||||
this.logger.info(`generating code for ${this.core.getAttribute(ptrNode, 'name')} using ${pluginId}`);
|
||||
if (genInfo.pluginId) {
|
||||
var context = {
|
||||
namespace: genInfo.namespace,
|
||||
activeNode: this.core.getPath(ptrNode)
|
||||
};
|
||||
|
||||
var context = {
|
||||
namespace: this.core.getNamespace(metanode),
|
||||
activeNode: this.core.getPath(ptrNode)
|
||||
};
|
||||
|
||||
// Load and run the plugin
|
||||
return this.executePlugin(pluginId, context);
|
||||
// Load and run the plugin
|
||||
return this.executePlugin(genInfo.pluginId, context);
|
||||
} else {
|
||||
var metanode = this.core.getMetaType(ptrNode),
|
||||
type = this.core.getAttribute(metanode, 'name');
|
||||
this.logger.warn(`Could not find plugin for ${type}. Will try to proceed anyway`);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.then(hashes => hashes[0]); // Grab the first asset for now
|
||||
};
|
||||
@@ -56,12 +93,13 @@ define([
|
||||
return PluginUtils.loadNodesAtCommitHash(
|
||||
this.project,
|
||||
this.core,
|
||||
this.commitHash,
|
||||
this.currentHash,
|
||||
this.logger,
|
||||
opts
|
||||
).then(config => {
|
||||
plugin.initialize(logger, this.blobClient, this.gmeConfig);
|
||||
config.core = this.core;
|
||||
config.project = this.project;
|
||||
plugin.configure(config);
|
||||
return plugin;
|
||||
});
|
||||
|
||||
@@ -42,8 +42,8 @@ define([
|
||||
embedded: true,
|
||||
widget: this.widget
|
||||
});
|
||||
this.control._onUnload = () => {
|
||||
ArchEditor.prototype._onUnload.apply(this.control, arguments);
|
||||
this.control._onUnload = id => {
|
||||
ArchEditor.prototype._onUnload.call(this.control, id);
|
||||
// If it was the last node, remove it
|
||||
var node = this.control._client.getNode(this.id);
|
||||
if (node.getChildrenIds().length === 0) {
|
||||
|
||||
@@ -34,7 +34,13 @@ define([
|
||||
this.enableTooltip(this._node.baseName, 'dark');
|
||||
}
|
||||
DecoratorBase.prototype.initialize.call(this);
|
||||
this.$name.on('dblclick', this.editName.bind(this));
|
||||
this.$name.on('click', () => {
|
||||
// Operations must already be selected. Otherwise, they will animate
|
||||
// after the edit name box is created and it will be placed incorrectly
|
||||
if (this.expanded || !this.isOperation()) {
|
||||
this.editName();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
OpIntDecorator.prototype.AttributeField = AttributeField;
|
||||
|
||||
@@ -173,7 +173,10 @@ define([
|
||||
name,
|
||||
i = 2;
|
||||
|
||||
basename = basename.replace(/[^\da-zA-Z_]/g, '_');
|
||||
basename = basename
|
||||
.replace(/^\s*/, '')
|
||||
.replace(/\s*$/, '')
|
||||
.replace(/[^\da-zA-Z_]/g, '_');
|
||||
name = basename;
|
||||
|
||||
// Get a unique name wrt the tags and the other executions
|
||||
|
||||
@@ -8,10 +8,10 @@ define([
|
||||
'plugin/PluginBase',
|
||||
'deepforge/plugin/LocalExecutor',
|
||||
'deepforge/plugin/PtrCodeGen',
|
||||
'deepforge/plugin/Operation',
|
||||
'deepforge/api/JobLogsClient',
|
||||
'deepforge/api/JobOriginClient',
|
||||
'deepforge/api/ExecPulseClient',
|
||||
'./ExecuteJob.Files',
|
||||
'./ExecuteJob.Metadata',
|
||||
'./ExecuteJob.SafeSave',
|
||||
'deepforge/Constants',
|
||||
@@ -26,11 +26,11 @@ define([
|
||||
PluginBase,
|
||||
LocalExecutor, // DeepForge operation primitives
|
||||
PtrCodeGen,
|
||||
OperationPlugin,
|
||||
JobLogsClient,
|
||||
JobOriginClient,
|
||||
ExecPulseClient,
|
||||
|
||||
ExecuteJobFiles,
|
||||
ExecuteJobMetadata,
|
||||
ExecuteJobSafeSave,
|
||||
|
||||
@@ -44,8 +44,7 @@ define([
|
||||
|
||||
pluginMetadata = JSON.parse(pluginMetadata);
|
||||
|
||||
var OUTPUT_INTERVAL = 1500,
|
||||
STDOUT_FILE = 'job_stdout.txt';
|
||||
var STDOUT_FILE = 'job_stdout.txt';
|
||||
|
||||
/**
|
||||
* Initializes a new instance of ExecuteJob.
|
||||
@@ -453,9 +452,10 @@ define([
|
||||
children.find(child => this.isMetaTypeOf(child, this.META.Operation)));
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.onBlobRetrievalFail = function (node, input, err) {
|
||||
// Handle the blob retrieval failed error
|
||||
ExecuteJob.prototype.onBlobRetrievalFail = function (node, input) {
|
||||
var job = this.core.getParent(node),
|
||||
e = `Failed to retrieve "${input}" (${err})`,
|
||||
e = `Failed to retrieve "${input}" (BLOB_FETCH_FAILED)`,
|
||||
consoleErr = `[0;31mFailed to execute operation: ${e}[0m`;
|
||||
|
||||
consoleErr += [
|
||||
@@ -473,14 +473,8 @@ define([
|
||||
|
||||
ExecuteJob.prototype.executeJob = function (job) {
|
||||
return this.getOperation(job).then(node => {
|
||||
var jobId = this.core.getPath(job),
|
||||
name = this.getAttribute(node, 'name'),
|
||||
localTypeId = this.getLocalOperationType(node),
|
||||
artifact,
|
||||
artifactName,
|
||||
files,
|
||||
data = {},
|
||||
inputs;
|
||||
var name = this.getAttribute(node, 'name'),
|
||||
localTypeId = this.getLocalOperationType(node);
|
||||
|
||||
// Execute any special operation types here - not on an executor
|
||||
this.logger.debug(`Executing operation "${name}"`);
|
||||
@@ -488,126 +482,22 @@ define([
|
||||
return this.executeLocalOperation(localTypeId, node);
|
||||
} else {
|
||||
// Generate all execution files
|
||||
return this.createOperationFiles(node).then(results => {
|
||||
this.logger.info('Created operation files!');
|
||||
files = results;
|
||||
artifactName = `${name}_${jobId.replace(/\//g, '_')}-execution-files`;
|
||||
artifact = this.blobClient.createArtifact(artifactName);
|
||||
|
||||
// Add the input assets
|
||||
// - get the metadata (name)
|
||||
// - add the given inputs
|
||||
inputs = Object.keys(files.inputAssets);
|
||||
|
||||
return Q.all(
|
||||
inputs.map(input => { // Get the metadata for each input
|
||||
var hash = files.inputAssets[input];
|
||||
|
||||
// data asset for "input"
|
||||
return this.blobClient.getMetadata(hash)
|
||||
.fail(err => this.onBlobRetrievalFail(job, input, err));
|
||||
})
|
||||
);
|
||||
})
|
||||
.then(mds => {
|
||||
// Record the large files
|
||||
var inputData = {},
|
||||
runsh = '# Bash script to download data files and run job\n' +
|
||||
'if [ -z "$DEEPFORGE_URL" ]; then\n echo "Please set DEEPFORGE_URL and' +
|
||||
' re-run:"\n echo "" \n echo " DEEPFORGE_URL=http://my.' +
|
||||
'deepforge.server.com:8080 bash run.sh"\n echo ""\n exit 1\nfi\n';
|
||||
|
||||
mds.forEach((metadata, i) => {
|
||||
// add the hashes for each input
|
||||
var input = inputs[i],
|
||||
hash = files.inputAssets[input],
|
||||
dataPath = 'inputs/' + input + '/data',
|
||||
url = this.blobClient.getRelativeDownloadURL(hash);
|
||||
|
||||
inputData[dataPath] = {
|
||||
req: hash,
|
||||
cache: metadata.content
|
||||
};
|
||||
|
||||
// Add to the run.sh file
|
||||
runsh += `wget $DEEPFORGE_URL${url} -O ${dataPath}\n`;
|
||||
return this.getPtrCodeHash(this.core.getPath(node))
|
||||
.fail(err => {
|
||||
this.logger.error(`Could not generate files: ${err}`);
|
||||
if (err.message.indexOf('BLOB_FETCH_FAILED') > -1) {
|
||||
this.onBlobRetrievalFail(node, err.message.split(':')[1]);
|
||||
}
|
||||
throw err;
|
||||
})
|
||||
.then(hash => {
|
||||
this.logger.info(`Saved execution files`);
|
||||
this.result.addArtifact(hash); // Probably only need this for debugging...
|
||||
this.executeDistOperation(job, node, hash);
|
||||
})
|
||||
.fail(e => {
|
||||
this.onOperationFail(node, `Distributed operation "${name}" failed ${e}`);
|
||||
});
|
||||
|
||||
delete files.inputAssets;
|
||||
files['input-data.json'] = JSON.stringify(inputData, null, 2);
|
||||
runsh += 'th init.lua';
|
||||
files['run.sh'] = runsh;
|
||||
|
||||
// Add pointer assets
|
||||
Object.keys(files.ptrAssets)
|
||||
.forEach(path => data[path] = files.ptrAssets[path]);
|
||||
|
||||
// Add the executor config
|
||||
return this.getOutputs(node);
|
||||
})
|
||||
.then(outputArgs => {
|
||||
var config,
|
||||
outputs,
|
||||
fileList,
|
||||
ptrFiles = Object.keys(files.ptrAssets),
|
||||
file;
|
||||
|
||||
delete files.ptrAssets;
|
||||
fileList = Object.keys(files).concat(ptrFiles);
|
||||
|
||||
outputs = outputArgs.map(pair => pair[0])
|
||||
.map(name => {
|
||||
return {
|
||||
name: name,
|
||||
resultPatterns: [`outputs/${name}`]
|
||||
};
|
||||
});
|
||||
|
||||
outputs.push(
|
||||
{
|
||||
name: 'stdout',
|
||||
resultPatterns: [STDOUT_FILE]
|
||||
},
|
||||
{
|
||||
name: name + '-all-files',
|
||||
resultPatterns: fileList
|
||||
}
|
||||
);
|
||||
|
||||
config = {
|
||||
cmd: 'node',
|
||||
args: ['start.js'],
|
||||
outputInterval: OUTPUT_INTERVAL,
|
||||
resultArtifacts: outputs
|
||||
};
|
||||
files['executor_config.json'] = JSON.stringify(config, null, 4);
|
||||
|
||||
// Save the artifact
|
||||
// Remove empty hashes
|
||||
for (file in data) {
|
||||
if (!data[file]) {
|
||||
this.logger.warn(`Empty data hash has been found for file "${file}". Removing it...`);
|
||||
delete data[file];
|
||||
}
|
||||
}
|
||||
return artifact.addObjectHashes(data);
|
||||
})
|
||||
.then(() => {
|
||||
this.logger.info(`Added ptr/input data hashes for "${artifactName}"`);
|
||||
return artifact.addFiles(files);
|
||||
})
|
||||
.then(() => {
|
||||
this.logger.info(`Added execution files for "${artifactName}"`);
|
||||
return artifact.save();
|
||||
})
|
||||
.then(hash => {
|
||||
this.logger.info(`Saved execution files "${artifactName}"`);
|
||||
this.result.addArtifact(hash); // Probably only need this for debugging...
|
||||
this.executeDistOperation(job, node, hash);
|
||||
})
|
||||
.fail(e => {
|
||||
this.onOperationFail(node, `Distributed operation "${name}" failed ${e}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -881,32 +771,6 @@ define([
|
||||
.fail(e => this.onOperationFail(node, `Operation ${nodeId} failed: ${e}`));
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.getOutputs = function (node) {
|
||||
return this.getOperationData(node, this.META.Outputs);
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.getInputs = function (node) {
|
||||
return this.getOperationData(node, this.META.Inputs);
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.getOperationData = function (node, metaType) {
|
||||
// Load the children and the output's children
|
||||
return this.core.loadChildren(node)
|
||||
.then(containers => {
|
||||
var outputs = containers.find(c => this.core.isTypeOf(c, metaType));
|
||||
return outputs ? this.core.loadChildren(outputs) : [];
|
||||
})
|
||||
.then(outputs => {
|
||||
var bases = outputs.map(node => this.core.getMetaType(node));
|
||||
// return [[arg1, Type1, node1], [arg2, Type2, node2]]
|
||||
return outputs.map((node, i) => [
|
||||
this.getAttribute(node, 'name'),
|
||||
this.getAttribute(bases[i], 'name'),
|
||||
node
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
//////////////////////////// Special Operations ////////////////////////////
|
||||
ExecuteJob.prototype.executeLocalOperation = function (type, node) {
|
||||
// Retrieve the given LOCAL_OP type
|
||||
@@ -920,7 +784,7 @@ define([
|
||||
|
||||
_.extend(
|
||||
ExecuteJob.prototype,
|
||||
ExecuteJobFiles.prototype,
|
||||
OperationPlugin.prototype,
|
||||
ExecuteJobMetadata.prototype,
|
||||
ExecuteJobSafeSave.prototype,
|
||||
PtrCodeGen.prototype,
|
||||
|
||||
@@ -175,6 +175,7 @@ define([
|
||||
ExecutePipeline.prototype.resumePipeline = function () {
|
||||
var nodes = Object.keys(this.nodes).map(id => this.nodes[id]),
|
||||
allJobs = nodes.filter(node => this.core.isTypeOf(node, this.META.Job)),
|
||||
name = this.getAttribute(this.activeNode, 'name'),
|
||||
status,
|
||||
jobs = {
|
||||
success: [],
|
||||
@@ -208,6 +209,7 @@ define([
|
||||
return Q.all(allJobs.map(job => this.recordOldMetadata(job, true)))
|
||||
.then(() => Q.all(jobs.success.map(job => this.getOperation(job))))
|
||||
.then(ops => ops.forEach(op => this.updateJobCompletionRecords(op)))
|
||||
.then(() => this.save(`Resuming pipeline execution: ${name}`))
|
||||
.then(() => {
|
||||
|
||||
if (jobs.running.length) { // Resume all running jobs
|
||||
@@ -531,10 +533,12 @@ define([
|
||||
this.logger.info(`Setting ${jobId} status to "success"`);
|
||||
this.logger.info(`There are now ${this.runningJobs} running jobs`);
|
||||
this.logger.debug(`Making a commit from ${this.currentHash}`);
|
||||
|
||||
counts = this.updateJobCompletionRecords(opNode);
|
||||
|
||||
this.save(`Operation "${name}" in ${this.pipelineName} completed successfully`)
|
||||
.then(() => {
|
||||
|
||||
counts = this.updateJobCompletionRecords(opNode);
|
||||
hasReadyOps = counts.indexOf(0) > -1;
|
||||
|
||||
this.logger.debug(`Operation "${name}" completed. ` +
|
||||
|
||||
@@ -1,29 +1,212 @@
|
||||
/*globals define*/
|
||||
/*jshint node:true, browser:true*/
|
||||
|
||||
define([
|
||||
'./templates/index',
|
||||
'q',
|
||||
'underscore',
|
||||
'deepforge/Constants'
|
||||
], function(
|
||||
'deepforge/Constants',
|
||||
'deepforge/plugin/Operation',
|
||||
'deepforge/plugin/PtrCodeGen',
|
||||
'text!./metadata.json',
|
||||
'plugin/PluginBase'
|
||||
], function (
|
||||
Templates,
|
||||
Q,
|
||||
_,
|
||||
CONSTANTS
|
||||
CONSTANTS,
|
||||
OperationHelpers,
|
||||
PtrCodeGen,
|
||||
pluginMetadata,
|
||||
PluginBase
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var SKIP_ATTRIBUTES = [
|
||||
'code',
|
||||
'stdout',
|
||||
'execFiles',
|
||||
'jobId',
|
||||
'secret',
|
||||
CONSTANTS.LINE_OFFSET,
|
||||
CONSTANTS.DISPLAY_COLOR
|
||||
];
|
||||
var ExecuteJob = function() {
|
||||
pluginMetadata = JSON.parse(pluginMetadata);
|
||||
var OUTPUT_INTERVAL = 1500,
|
||||
STDOUT_FILE = 'job_stdout.txt',
|
||||
SKIP_ATTRIBUTES = [
|
||||
'code',
|
||||
'stdout',
|
||||
'execFiles',
|
||||
'jobId',
|
||||
'secret',
|
||||
CONSTANTS.LINE_OFFSET,
|
||||
CONSTANTS.DISPLAY_COLOR
|
||||
];
|
||||
|
||||
/**
|
||||
* Initializes a new instance of GenerateJob.
|
||||
* @class
|
||||
* @augments {PluginBase}
|
||||
* @classdesc This class represents the plugin GenerateJob.
|
||||
* @constructor
|
||||
*/
|
||||
var GenerateJob = function () {
|
||||
// Call base class' constructor.
|
||||
PluginBase.call(this);
|
||||
this.pluginMetadata = pluginMetadata;
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createOperationFiles = function (node) {
|
||||
/**
|
||||
* Metadata associated with the plugin. Contains id, name, version, description, icon, configStructue etc.
|
||||
* This is also available at the instance at this.pluginMetadata.
|
||||
* @type {object}
|
||||
*/
|
||||
GenerateJob.metadata = pluginMetadata;
|
||||
|
||||
// Prototypical inheritance from PluginBase.
|
||||
GenerateJob.prototype = Object.create(PluginBase.prototype);
|
||||
GenerateJob.prototype.constructor = GenerateJob;
|
||||
|
||||
/**
|
||||
* Main function for the plugin to execute. This will perform the execution.
|
||||
* Notes:
|
||||
* - Always log with the provided logger.[error,warning,info,debug].
|
||||
* - Do NOT put any user interaction logic UI, etc. inside this method.
|
||||
* - callback always has to be called even if error happened.
|
||||
*
|
||||
* @param {function(string, plugin.PluginResult)} callback - the result callback
|
||||
*/
|
||||
GenerateJob.prototype.main = function (callback) {
|
||||
var files,
|
||||
artifactName,
|
||||
artifact,
|
||||
data = {},
|
||||
inputs,
|
||||
name,
|
||||
opId;
|
||||
|
||||
name = this.getAttribute(this.activeNode, 'name');
|
||||
opId = this.core.getPath(this.activeNode);
|
||||
|
||||
return this.createOperationFiles(this.activeNode)
|
||||
.then(results => {
|
||||
this.logger.info('Created operation files!');
|
||||
files = results;
|
||||
artifactName = `${name}_${opId.replace(/\//g, '_')}-execution-files`;
|
||||
artifact = this.blobClient.createArtifact(artifactName);
|
||||
|
||||
// Add the input assets
|
||||
// - get the metadata (name)
|
||||
// - add the given inputs
|
||||
inputs = Object.keys(files.inputAssets);
|
||||
|
||||
return Q.all(
|
||||
inputs.map(input => { // Get the metadata for each input
|
||||
var hash = files.inputAssets[input];
|
||||
|
||||
// data asset for "input"
|
||||
return this.blobClient.getMetadata(hash)
|
||||
.fail(() => {
|
||||
throw Error(`BLOB_FETCH_FAILED:${input}`);
|
||||
});
|
||||
})
|
||||
);
|
||||
})
|
||||
.then(mds => {
|
||||
// Record the large files
|
||||
var inputData = {},
|
||||
runsh = '# Bash script to download data files and run job\n' +
|
||||
'if [ -z "$DEEPFORGE_URL" ]; then\n echo "Please set DEEPFORGE_URL and' +
|
||||
' re-run:"\n echo "" \n echo " DEEPFORGE_URL=http://my.' +
|
||||
'deepforge.server.com:8080 bash run.sh"\n echo ""\n exit 1\nfi\n';
|
||||
|
||||
mds.forEach((metadata, i) => {
|
||||
// add the hashes for each input
|
||||
var input = inputs[i],
|
||||
hash = files.inputAssets[input],
|
||||
dataPath = 'inputs/' + input + '/data',
|
||||
url = this.blobClient.getRelativeDownloadURL(hash);
|
||||
|
||||
inputData[dataPath] = {
|
||||
req: hash,
|
||||
cache: metadata.content
|
||||
};
|
||||
|
||||
// Add to the run.sh file
|
||||
runsh += `wget $DEEPFORGE_URL${url} -O ${dataPath}\n`;
|
||||
});
|
||||
|
||||
delete files.inputAssets;
|
||||
files['input-data.json'] = JSON.stringify(inputData, null, 2);
|
||||
runsh += 'th init.lua';
|
||||
files['run.sh'] = runsh;
|
||||
|
||||
// Add pointer assets
|
||||
Object.keys(files.ptrAssets)
|
||||
.forEach(path => data[path] = files.ptrAssets[path]);
|
||||
|
||||
// Add the executor config
|
||||
return this.getOutputs(this.activeNode);
|
||||
})
|
||||
.then(outputArgs => {
|
||||
var config,
|
||||
outputs,
|
||||
fileList,
|
||||
ptrFiles = Object.keys(files.ptrAssets),
|
||||
file;
|
||||
|
||||
delete files.ptrAssets;
|
||||
fileList = Object.keys(files).concat(ptrFiles);
|
||||
|
||||
outputs = outputArgs.map(pair => pair[0])
|
||||
.map(name => {
|
||||
return {
|
||||
name: name,
|
||||
resultPatterns: [`outputs/${name}`]
|
||||
};
|
||||
});
|
||||
|
||||
outputs.push(
|
||||
{
|
||||
name: 'stdout',
|
||||
resultPatterns: [STDOUT_FILE]
|
||||
},
|
||||
{
|
||||
name: name + '-all-files',
|
||||
resultPatterns: fileList
|
||||
}
|
||||
);
|
||||
|
||||
config = {
|
||||
cmd: 'node',
|
||||
args: ['start.js'],
|
||||
outputInterval: OUTPUT_INTERVAL,
|
||||
resultArtifacts: outputs
|
||||
};
|
||||
files['executor_config.json'] = JSON.stringify(config, null, 4);
|
||||
|
||||
// Save the artifact
|
||||
// Remove empty hashes
|
||||
for (file in data) {
|
||||
if (!data[file]) {
|
||||
this.logger.warn(`Empty data hash has been found for file "${file}". Removing it...`);
|
||||
delete data[file];
|
||||
}
|
||||
}
|
||||
return artifact.addObjectHashes(data);
|
||||
})
|
||||
.then(() => {
|
||||
this.logger.info(`Added ptr/input data hashes for "${artifactName}"`);
|
||||
return artifact.addFiles(files);
|
||||
})
|
||||
.then(() => {
|
||||
this.logger.info(`Added execution files for "${artifactName}"`);
|
||||
return artifact.save();
|
||||
})
|
||||
.then(hash => {
|
||||
this.result.setSuccess(true);
|
||||
this.result.addArtifact(hash);
|
||||
callback(null, this.result);
|
||||
})
|
||||
.fail(err => {
|
||||
this.result.setSuccess(false);
|
||||
callback(err, this.result);
|
||||
});
|
||||
};
|
||||
|
||||
GenerateJob.prototype.createOperationFiles = function (node) {
|
||||
var files = {};
|
||||
// For each operation, generate the output files:
|
||||
// inputs/<arg-name>/init.lua (respective data deserializer)
|
||||
@@ -47,10 +230,14 @@ define([
|
||||
.then(() => {
|
||||
this.createAttributeFile(node, files);
|
||||
return Q.ninvoke(this, 'createPointers', node, files);
|
||||
})
|
||||
.fail(err => {
|
||||
this.logger.error(err);
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createEntryFile = function (node, files) {
|
||||
GenerateJob.prototype.createEntryFile = function (node, files) {
|
||||
this.logger.info('Creating entry files...');
|
||||
return this.getOutputs(node)
|
||||
.then(outputs => {
|
||||
@@ -68,7 +255,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createClasses = function (node, files) {
|
||||
GenerateJob.prototype.createClasses = function (node, files) {
|
||||
var metaDict = this.core.getAllMetaNodes(this.rootNode),
|
||||
isClass,
|
||||
metanodes,
|
||||
@@ -120,7 +307,7 @@ define([
|
||||
files['classes/init.lua'] = code;
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.getTypeDictFor = function (name, metanodes) {
|
||||
GenerateJob.prototype.getTypeDictFor = function (name, metanodes) {
|
||||
var isType = {};
|
||||
// Get all the custom layers
|
||||
for (var i = metanodes.length; i--;) {
|
||||
@@ -131,7 +318,7 @@ define([
|
||||
return isType;
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createCustomLayers = function (node, files) {
|
||||
GenerateJob.prototype.createCustomLayers = function (node, files) {
|
||||
var metaDict = this.core.getAllMetaNodes(this.rootNode),
|
||||
isCustomLayer,
|
||||
metanodes,
|
||||
@@ -153,7 +340,29 @@ define([
|
||||
files['custom-layers.lua'] = code;
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createInputs = function (node, files) {
|
||||
GenerateJob.prototype.getConnectionContainer = function () {
|
||||
var container = this.core.getParent(this.activeNode);
|
||||
|
||||
if (this.isMetaTypeOf(container, this.META.Job)) {
|
||||
container = this.core.getParent(container);
|
||||
}
|
||||
|
||||
return container;
|
||||
};
|
||||
|
||||
GenerateJob.prototype.getInputPortsFor = function (nodeId) {
|
||||
var container = this.getConnectionContainer();
|
||||
|
||||
// Get the connections to this node
|
||||
return this.core.loadChildren(container)
|
||||
.then(children => {
|
||||
return children.filter(child =>
|
||||
this.core.getPointerPath(child, 'dst') === nodeId)
|
||||
.map(conn => this.core.getPointerPath(conn, 'src'))[0];
|
||||
});
|
||||
};
|
||||
|
||||
GenerateJob.prototype.createInputs = function (node, files) {
|
||||
var tplContents,
|
||||
inputs;
|
||||
|
||||
@@ -174,15 +383,13 @@ define([
|
||||
return Q.all(inputs.map(pair => {
|
||||
var name = pair[0],
|
||||
node = pair[2],
|
||||
nodeId = this.core.getPath(node),
|
||||
fromNodeId;
|
||||
nodeId = this.core.getPath(node);
|
||||
|
||||
// Get the deserialize function. First, try to get it from
|
||||
// the source method (this guarantees that the correct
|
||||
// deserialize method is used despite any auto-upcasting
|
||||
fromNodeId = this.inputPortsFor[nodeId][0] || nodeId;
|
||||
|
||||
return this.core.loadByPath(this.rootNode, fromNodeId)
|
||||
return this.getInputPortsFor(nodeId)
|
||||
.then(fromNodeId => this.core.loadByPath(this.rootNode, fromNodeId || nodeId))
|
||||
.then(fromNode => {
|
||||
var deserFn,
|
||||
base,
|
||||
@@ -218,7 +425,9 @@ define([
|
||||
|
||||
return Q.all(hashes.map(pair =>
|
||||
this.blobClient.getMetadata(pair.hash)
|
||||
.fail(err => this.onBlobRetrievalFail(node, pair.name, err))));
|
||||
.fail(() => {
|
||||
throw Error(`BLOB_FETCH_FAILED:${pair.name}`);
|
||||
})));
|
||||
})
|
||||
.then(metadatas => {
|
||||
// Create the deserializer
|
||||
@@ -231,7 +440,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createOutputs = function (node, files) {
|
||||
GenerateJob.prototype.createOutputs = function (node, files) {
|
||||
// For each of the output types, grab their serialization functions and
|
||||
// create the `outputs/init.lua` file
|
||||
this.logger.info('Creating outputs/init.lua...');
|
||||
@@ -256,7 +465,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createMainFile = function (node, files) {
|
||||
GenerateJob.prototype.createMainFile = function (node, files) {
|
||||
this.logger.info('Creating main file...');
|
||||
return this.getInputs(node)
|
||||
.then(inputs => {
|
||||
@@ -286,14 +495,14 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.getLineOffset = function (main, snippet) {
|
||||
GenerateJob.prototype.getLineOffset = function (main, snippet) {
|
||||
var i = main.indexOf(snippet),
|
||||
lines = main.substring(0, i).match(/\n/g);
|
||||
|
||||
return lines ? lines.length : 0;
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createAttributeFile = function (node, files) {
|
||||
GenerateJob.prototype.createAttributeFile = function (node, files) {
|
||||
var numOrBool = /^(-?\d+\.?\d*((e|e-)\d+)?|(true|false))$/,
|
||||
table;
|
||||
|
||||
@@ -305,7 +514,7 @@ define([
|
||||
if (!numOrBool.test(value)) {
|
||||
value = `"${value}"`;
|
||||
}
|
||||
return [name, value];
|
||||
return [`['${name}']`, value];
|
||||
})
|
||||
.map(pair => pair.join(' = '))
|
||||
.join(',\n\t') + '\n}';
|
||||
@@ -313,7 +522,7 @@ define([
|
||||
files['attributes.lua'] = `-- attributes of ${this.getAttribute(node, 'name')}\nreturn ${table}`;
|
||||
};
|
||||
|
||||
ExecuteJob.prototype.createPointers = function (node, files, cb) {
|
||||
GenerateJob.prototype.createPointers = function (node, files, cb) {
|
||||
var pointers,
|
||||
nIds;
|
||||
|
||||
@@ -341,6 +550,19 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
return ExecuteJob;
|
||||
});
|
||||
GenerateJob.prototype.getAttribute = function (node, attr) {
|
||||
return this.core.getAttribute(node, attr);
|
||||
};
|
||||
|
||||
GenerateJob.prototype.setAttribute = function (node, attr, value) {
|
||||
return this.core.setAttribute(node, attr, value);
|
||||
};
|
||||
|
||||
_.extend(
|
||||
GenerateJob.prototype,
|
||||
OperationHelpers.prototype,
|
||||
PtrCodeGen.prototype
|
||||
);
|
||||
|
||||
return GenerateJob;
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "GenerateJob",
|
||||
"name": "GenerateJob",
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"icon": {
|
||||
"class": "glyphicon glyphicon-cog",
|
||||
"src": ""
|
||||
},
|
||||
"disableServerSideExecution": false,
|
||||
"disableBrowserSideExecution": false,
|
||||
"writeAccessRequired": false,
|
||||
"configStructure": []
|
||||
}
|
||||
@@ -213,10 +213,10 @@ requirejs([
|
||||
job = null;
|
||||
log(`killing process group: ${pid}`);
|
||||
process.kill(-pid, 'SIGTERM');
|
||||
if (exitCode !== null) {
|
||||
log(`exiting w/ code ${exitCode}`);
|
||||
process.exit(exitCode);
|
||||
}
|
||||
}
|
||||
if (exitCode !== null) {
|
||||
log(`exiting w/ code ${exitCode}`);
|
||||
process.exit(exitCode);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -660,9 +660,9 @@ define([
|
||||
items = this._client.getAllMetaNodes()
|
||||
.filter(node => node.isTypeOf(criterionId));
|
||||
|
||||
return items.map(id => {
|
||||
return items.map(node => {
|
||||
return {
|
||||
node: this._getObjectDescriptor(id)
|
||||
node: this._getObjectDescriptor(node.getId())
|
||||
};
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -61,9 +61,11 @@ define([
|
||||
var layer = this;
|
||||
this._widget.showHoverButtons(layer);
|
||||
};
|
||||
|
||||
this.ItemClass.prototype.hideHoverButtons = function() {
|
||||
this._widget.hideHoverButtons();
|
||||
};
|
||||
|
||||
this.ItemClass.prototype.isHoverAllowed = function() {
|
||||
return !this._widget.isConnecting();
|
||||
};
|
||||
@@ -169,6 +171,7 @@ define([
|
||||
createNews = Object.keys(types).map(type =>
|
||||
this._creationNode(type, types[type], Decorator));
|
||||
|
||||
nodes.sort((a, b) => a.node.name < b.node.name ? -1 : 1);
|
||||
nodes = nodes.concat(createNews);
|
||||
|
||||
// Sort by layer type
|
||||
|
||||
@@ -11,6 +11,9 @@ define([
|
||||
DAGItem.call(this, parentEl, desc);
|
||||
this.decorator.color = desc.displayColor || this.decorator.color;
|
||||
|
||||
this._hovering = false;
|
||||
this.$el.on('mouseenter', () => this.onHover());
|
||||
this.$el.on('mouseleave', () => this._hovering && this.onUnhover());
|
||||
|
||||
// Show the warnings
|
||||
this.$warning = null;
|
||||
@@ -19,6 +22,18 @@ define([
|
||||
};
|
||||
|
||||
_.extend(Item.prototype, DAGItem.prototype);
|
||||
|
||||
Item.prototype.onUnhover = function() {
|
||||
this._hovering = false;
|
||||
this.hideHoverButtons();
|
||||
};
|
||||
|
||||
Item.prototype.onHover = function() {
|
||||
if (!this.isSelected()) {
|
||||
this._hovering = true;
|
||||
this.showHoverButtons();
|
||||
}
|
||||
};
|
||||
|
||||
Item.prototype.update = function(desc) {
|
||||
this.decorator.color = desc.displayColor || this.decorator.color;
|
||||
@@ -82,6 +97,10 @@ define([
|
||||
if (this.desc.isUnknown) {
|
||||
this.onSetRefClicked(this.desc.name);
|
||||
}
|
||||
|
||||
if (this._hovering) {
|
||||
this.onUnhover();
|
||||
}
|
||||
};
|
||||
|
||||
Item.prototype.setupDecoratorCallbacks = function() {
|
||||
|
||||
@@ -6,6 +6,7 @@ define([
|
||||
'widgets/EasyDAG/EasyDAGWidget',
|
||||
'widgets/EasyDAG/AddNodeDialog',
|
||||
'./SelectionManager',
|
||||
'./Buttons',
|
||||
'./Item',
|
||||
'underscore',
|
||||
'css!./styles/OperationInterfaceEditorWidget.css'
|
||||
@@ -14,6 +15,7 @@ define([
|
||||
EasyDAG,
|
||||
AddNodeDialog,
|
||||
SelectionManager,
|
||||
Buttons,
|
||||
Item,
|
||||
_
|
||||
) {
|
||||
@@ -38,6 +40,20 @@ define([
|
||||
// Add ptr rename callback
|
||||
this.ItemClass.prototype.changePtrName = (from, to) => this.changePtrName(from, to);
|
||||
this.ItemClass.prototype.onSetRefClicked = OperationInterfaceEditorWidget.prototype.onSetRefClicked.bind(this);
|
||||
|
||||
this.ItemClass.prototype.showHoverButtons = function() {
|
||||
var item = this;
|
||||
this._widget.showHoverButtons(item);
|
||||
};
|
||||
|
||||
this.ItemClass.prototype.hideHoverButtons = function() {
|
||||
this._widget.hideHoverButtons();
|
||||
};
|
||||
|
||||
this.ItemClass.prototype.isHoverAllowed = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
OperationInterfaceEditorWidget.prototype.onAddItemSelected = function(selected, isInput) {
|
||||
@@ -126,5 +142,57 @@ define([
|
||||
conn.$el.on('click', null);
|
||||
};
|
||||
|
||||
// Hover buttons
|
||||
OperationInterfaceEditorWidget.prototype.showHoverButtons = function(item) {
|
||||
var dataNodes = this.allDataTypeIds(),
|
||||
refNodes = this.allValidReferences(),
|
||||
height = item.height,
|
||||
cx = item.width/2;
|
||||
|
||||
if (this.$hoverBtns) {
|
||||
this.hideHoverButtons();
|
||||
}
|
||||
|
||||
this.$hoverBtns = item.$el
|
||||
.append('g')
|
||||
.attr('class', 'hover-container');
|
||||
|
||||
if (item.desc.baseName === 'Operation') {
|
||||
new Buttons.AddOutput({ // Add output data
|
||||
context: this,
|
||||
$pEl: this.$hoverBtns,
|
||||
disabled: dataNodes.length === 0,
|
||||
item: item,
|
||||
x: cx,
|
||||
y: height
|
||||
});
|
||||
|
||||
new Buttons.AddInput({ // Add input data
|
||||
context: this,
|
||||
$pEl: this.$hoverBtns,
|
||||
disabled: dataNodes.length === 0,
|
||||
item: item,
|
||||
x: item.width/3,
|
||||
y: 0
|
||||
});
|
||||
|
||||
new Buttons.AddRef({ // Add reference
|
||||
context: this,
|
||||
$pEl: this.$hoverBtns,
|
||||
disabled: refNodes.length === 0,
|
||||
item: item,
|
||||
x: 2*item.width/3,
|
||||
y: 0
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
OperationInterfaceEditorWidget.prototype.hideHoverButtons = function() {
|
||||
if (this.$hoverBtns) {
|
||||
this.$hoverBtns.remove();
|
||||
this.$hoverBtns = null;
|
||||
}
|
||||
};
|
||||
|
||||
return OperationInterfaceEditorWidget;
|
||||
});
|
||||
|
||||
@@ -5,16 +5,24 @@ define([
|
||||
'ace/ace',
|
||||
'underscore',
|
||||
'./completer',
|
||||
'js/Utils/ComponentSettings',
|
||||
'jquery-contextMenu',
|
||||
'css!./styles/TextEditorWidget.css'
|
||||
], function (
|
||||
ace,
|
||||
_,
|
||||
Completer
|
||||
Completer,
|
||||
ComponentSettings
|
||||
) {
|
||||
'use strict';
|
||||
|
||||
var TextEditorWidget,
|
||||
WIDGET_CLASS = 'text-editor';
|
||||
WIDGET_CLASS = 'text-editor',
|
||||
DEFAULT_SETTINGS = {
|
||||
keybindings: 'default',
|
||||
theme: 'solarized_dark',
|
||||
fontSize: 12
|
||||
};
|
||||
|
||||
TextEditorWidget = function (logger, container) {
|
||||
this._logger = logger.fork('Widget');
|
||||
@@ -27,9 +35,13 @@ define([
|
||||
|
||||
this.readOnly = this.readOnly || false;
|
||||
this.editor = ace.edit(this.$editor[0]);
|
||||
this._initialize();
|
||||
|
||||
// Get the config from component settings for themes
|
||||
this.editor.getSession().setOptions(this.getSessionOptions());
|
||||
var handler = this.editorSettings.keybindings;
|
||||
this.editor.setKeyboardHandler(handler === 'default' ?
|
||||
null : 'ace/keyboard/' + handler);
|
||||
this.addExtensions();
|
||||
this.editor.$blockScrolling = Infinity;
|
||||
this.DELAY = 750;
|
||||
@@ -47,7 +59,6 @@ define([
|
||||
this.setReadOnly(this.readOnly);
|
||||
this.currentHeader = '';
|
||||
this.activeNode = null;
|
||||
this._initialize();
|
||||
|
||||
this._logger.debug('ctor finished');
|
||||
};
|
||||
@@ -68,7 +79,8 @@ define([
|
||||
return {
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
fontSize: '12pt'
|
||||
theme: 'ace/theme/' + this.editorSettings.theme,
|
||||
fontSize: this.editorSettings.fontSize + 'pt'
|
||||
};
|
||||
};
|
||||
|
||||
@@ -83,6 +95,124 @@ define([
|
||||
TextEditorWidget.prototype._initialize = function () {
|
||||
// set widget class
|
||||
this._el.addClass(WIDGET_CLASS);
|
||||
|
||||
// Add context menu
|
||||
$.contextMenu('destroy', '.' + WIDGET_CLASS);
|
||||
$.contextMenu({
|
||||
selector: '.' + WIDGET_CLASS,
|
||||
build: $trigger => {
|
||||
return {
|
||||
items: this.getMenuItemsFor($trigger)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Create the editor settings
|
||||
this.editorSettings = _.extend({}, DEFAULT_SETTINGS),
|
||||
ComponentSettings.resolveWithWebGMEGlobal(
|
||||
this.editorSettings,
|
||||
this.getComponentId()
|
||||
);
|
||||
};
|
||||
|
||||
TextEditorWidget.prototype.getComponentId = function () {
|
||||
return 'TextEditor';
|
||||
};
|
||||
|
||||
TextEditorWidget.prototype.getMenuItemsFor = function () {
|
||||
var fontSizes = [8, 10, 11, 12, 14],
|
||||
themes = [
|
||||
'Solarized Light',
|
||||
'Solarized Dark',
|
||||
'Twilight',
|
||||
'Tomorrow Night',
|
||||
'Eclipse',
|
||||
'Monokai'
|
||||
],
|
||||
keybindings = [
|
||||
'default',
|
||||
'vim',
|
||||
'emacs'
|
||||
],
|
||||
menuItems = {
|
||||
setKeybindings: {
|
||||
name: 'Keybindings...',
|
||||
items: {}
|
||||
},
|
||||
setFontSize: {
|
||||
name: 'Font Size...',
|
||||
items: {}
|
||||
},
|
||||
setTheme: {
|
||||
name: 'Theme...',
|
||||
items: {}
|
||||
}
|
||||
};
|
||||
|
||||
fontSizes.forEach(fontSize => {
|
||||
var name = fontSize + ' pt',
|
||||
isSet = fontSize === this.editorSettings.fontSize;
|
||||
|
||||
if (isSet) {
|
||||
name = '<span style="font-weight: bold">' + name + '</span>';
|
||||
}
|
||||
|
||||
menuItems.setFontSize.items['font' + fontSize] = {
|
||||
name: name,
|
||||
isHtmlName: isSet,
|
||||
callback: () => {
|
||||
this.editorSettings.fontSize = fontSize;
|
||||
this.editor.setOptions(this.getEditorOptions());
|
||||
this.onUpdateEditorSettings();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
themes.forEach(name => {
|
||||
var theme = name.toLowerCase().replace(/ /g, '_'),
|
||||
isSet = theme === this.editorSettings.theme;
|
||||
|
||||
if (isSet) {
|
||||
name = '<span style="font-weight: bold">' + name + '</span>';
|
||||
}
|
||||
|
||||
menuItems.setTheme.items[theme] = {
|
||||
name: name,
|
||||
isHtmlName: isSet,
|
||||
callback: () => {
|
||||
this.editorSettings.theme = theme;
|
||||
this.editor.setOptions(this.getEditorOptions());
|
||||
this.onUpdateEditorSettings();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
keybindings.forEach(name => {
|
||||
var handler = name.toLowerCase().replace(/ /g, '_'),
|
||||
isSet = handler === this.editorSettings.keybindings;
|
||||
|
||||
if (isSet) {
|
||||
name = '<span style="font-weight: bold">' + name + '</span>';
|
||||
}
|
||||
|
||||
menuItems.setKeybindings.items[handler] = {
|
||||
name: name,
|
||||
isHtmlName: isSet,
|
||||
callback: () => {
|
||||
this.editorSettings.keybindings = handler;
|
||||
this.editor.setKeyboardHandler(handler === 'default' ?
|
||||
null : 'ace/keyboard/' + handler);
|
||||
this.onUpdateEditorSettings();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return menuItems;
|
||||
};
|
||||
|
||||
TextEditorWidget.prototype.onUpdateEditorSettings = function () {
|
||||
ComponentSettings.overwriteComponentSettings(this.getComponentId(), this.editorSettings,
|
||||
err => err && this._logger.error(`Could not save editor settings: ${err}`));
|
||||
};
|
||||
|
||||
TextEditorWidget.prototype.onWidgetContainerResize = function () {
|
||||
@@ -147,6 +277,7 @@ define([
|
||||
/* * * * * * * * Visualizer life cycle callbacks * * * * * * * */
|
||||
TextEditorWidget.prototype.destroy = function () {
|
||||
this.editor.destroy();
|
||||
$.contextMenu('destroy', '.' + WIDGET_CLASS);
|
||||
};
|
||||
|
||||
TextEditorWidget.prototype.onActivate = function () {
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('CreateExecution', function () {
|
||||
expect = testFixture.expect,
|
||||
logger = testFixture.logger.fork('CreateExecution'),
|
||||
PluginCliManager = testFixture.WebGME.PluginCliManager,
|
||||
manager = new PluginCliManager(null, logger, gmeConfig),
|
||||
projectName = 'testProject',
|
||||
pluginName = 'CreateExecution',
|
||||
project,
|
||||
@@ -28,7 +29,7 @@ describe('CreateExecution', function () {
|
||||
})
|
||||
.then(function () {
|
||||
var importParam = {
|
||||
projectSeed: testFixture.path.join(testFixture.SEED_DIR, 'EmptyProject.webgmex'),
|
||||
projectSeed: testFixture.path.join(testFixture.DF_SEED_DIR, 'devProject', 'devProject.webgmex'),
|
||||
projectName: projectName,
|
||||
branchName: 'master',
|
||||
logger: logger,
|
||||
@@ -53,27 +54,49 @@ describe('CreateExecution', function () {
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it.skip('should run plugin and update the branch', function (done) {
|
||||
var manager = new PluginCliManager(null, logger, gmeConfig),
|
||||
pluginConfig = {
|
||||
},
|
||||
context = {
|
||||
var plugin,
|
||||
node,
|
||||
preparePlugin = function(done) {
|
||||
var context = {
|
||||
project: project,
|
||||
commitHash: commitHash,
|
||||
namespace: 'pipeline',
|
||||
branchName: 'test',
|
||||
activeNode: '/1'
|
||||
activeNode: '/K/R/p' // hello world job
|
||||
};
|
||||
|
||||
manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) {
|
||||
expect(err).to.equal(null);
|
||||
expect(typeof pluginResult).to.equal('object');
|
||||
expect(pluginResult.success).to.equal(true);
|
||||
return manager.initializePlugin(pluginName)
|
||||
.then(plugin_ => {
|
||||
plugin = plugin_;
|
||||
return manager.configurePlugin(plugin, {}, context);
|
||||
})
|
||||
.then(() => node = plugin.activeNode)
|
||||
.nodeify(done);
|
||||
};
|
||||
|
||||
project.getBranchHash('test')
|
||||
.then(function (branchHash) {
|
||||
expect(branchHash).to.not.equal(commitHash);
|
||||
describe('getUniqueExecName', function() {
|
||||
|
||||
before(preparePlugin);
|
||||
|
||||
it('should trim whitespace', function(done) {
|
||||
var name = ' abc ';
|
||||
|
||||
plugin.getUniqueExecName(name)
|
||||
.then(name => {
|
||||
expect(name).to.equal('abc');
|
||||
})
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it('should replace whitespace with _', function(done) {
|
||||
var name = 'a b c';
|
||||
|
||||
plugin.getUniqueExecName(name)
|
||||
.then(name => {
|
||||
expect(name).to.equal('a_b_c');
|
||||
})
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -300,62 +300,6 @@ describe('ExecuteJob', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('exec files', function() {
|
||||
describe('attribute file', function() {
|
||||
var boolString = /['"](true|false)['"]/g;
|
||||
|
||||
beforeEach(preparePlugin);
|
||||
|
||||
it('should not quote true (s) boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', 'true');
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
|
||||
it('should not quote true boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', true);
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
|
||||
it('should not quote false (s) boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', 'false');
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
|
||||
it('should not quote false boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', false);
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('resume detection', function() {
|
||||
var mockPluginForJobStatus = function(gmeStatus, pulse, originBranch, shouldResume, done) {
|
||||
plugin.setAttribute(node, 'status', gmeStatus);
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*jshint node:true, mocha:true*/
|
||||
/**
|
||||
* Generated by PluginGenerator 1.7.0 from webgme on Mon Apr 17 2017 07:34:11 GMT-0500 (CDT).
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
var testFixture = require('../../globals');
|
||||
|
||||
describe('GenerateJob', function () {
|
||||
var gmeConfig = testFixture.getGmeConfig(),
|
||||
expect = testFixture.expect,
|
||||
logger = testFixture.logger.fork('GenerateJob'),
|
||||
PluginCliManager = testFixture.WebGME.PluginCliManager,
|
||||
manager = new PluginCliManager(null, logger, gmeConfig),
|
||||
projectName = 'testProject',
|
||||
pluginName = 'GenerateJob',
|
||||
project,
|
||||
gmeAuth,
|
||||
storage,
|
||||
commitHash;
|
||||
|
||||
before(function (done) {
|
||||
testFixture.clearDBAndGetGMEAuth(gmeConfig, projectName)
|
||||
.then(function (gmeAuth_) {
|
||||
gmeAuth = gmeAuth_;
|
||||
// This uses in memory storage. Use testFixture.getMongoStorage to persist test to database.
|
||||
storage = testFixture.getMemoryStorage(logger, gmeConfig, gmeAuth);
|
||||
return storage.openDatabase();
|
||||
})
|
||||
.then(function () {
|
||||
var importParam = {
|
||||
projectSeed: testFixture.path.join(testFixture.DF_SEED_DIR, 'devProject', 'devProject.webgmex'),
|
||||
projectName: projectName,
|
||||
branchName: 'master',
|
||||
logger: logger,
|
||||
gmeConfig: gmeConfig
|
||||
};
|
||||
|
||||
return testFixture.importProject(storage, importParam);
|
||||
})
|
||||
.then(function (importResult) {
|
||||
project = importResult.project;
|
||||
commitHash = importResult.commitHash;
|
||||
return project.createBranch('test', commitHash);
|
||||
})
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
storage.closeDatabase()
|
||||
.then(function () {
|
||||
return gmeAuth.unload();
|
||||
})
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
describe('basic checks', function() {
|
||||
var pluginResult,
|
||||
error;
|
||||
|
||||
before(function(done) {
|
||||
var pluginConfig = {
|
||||
},
|
||||
context = {
|
||||
project: project,
|
||||
commitHash: commitHash,
|
||||
branchName: 'test',
|
||||
activeNode: '/1',
|
||||
};
|
||||
|
||||
manager.executePlugin(pluginName, pluginConfig, context, (err, result) => {
|
||||
error = err;
|
||||
pluginResult = result;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should run without error', function () {
|
||||
expect(error).to.equal(null);
|
||||
expect(typeof pluginResult).to.equal('object');
|
||||
expect(pluginResult.success).to.equal(true);
|
||||
});
|
||||
|
||||
it('should generate artifacts', function () {
|
||||
expect(pluginResult.artifacts[0]).to.not.equal(undefined);
|
||||
});
|
||||
|
||||
it('should NOT update the branch', function (done) {
|
||||
project.getBranchHash('test')
|
||||
.then(function (branchHash) {
|
||||
expect(branchHash).to.equal(commitHash);
|
||||
})
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
////////// Helper Functions //////////
|
||||
var plugin,
|
||||
node,
|
||||
preparePlugin = function(done) {
|
||||
var context = {
|
||||
project: project,
|
||||
commitHash: commitHash,
|
||||
namespace: 'pipeline',
|
||||
branchName: 'test',
|
||||
activeNode: '/K/R/p/m' // hello world operation
|
||||
};
|
||||
|
||||
return manager.initializePlugin(pluginName)
|
||||
.then(plugin_ => {
|
||||
plugin = plugin_;
|
||||
return manager.configurePlugin(plugin, {}, context);
|
||||
})
|
||||
.then(() => node = plugin.activeNode)
|
||||
.nodeify(done);
|
||||
};
|
||||
|
||||
describe('exec files', function() {
|
||||
describe('attribute file', function() {
|
||||
var boolString = /['"](true|false)['"]/g;
|
||||
|
||||
beforeEach(preparePlugin);
|
||||
|
||||
it('should not quote true (s) boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', 'true');
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
|
||||
it('should not quote true boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', true);
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
|
||||
it('should not quote false (s) boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', 'false');
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
|
||||
it('should not quote false boolean values', function() {
|
||||
var files = {},
|
||||
content,
|
||||
matches;
|
||||
|
||||
plugin.setAttribute(node, 'debug', false);
|
||||
plugin.createAttributeFile(node, files);
|
||||
content = files['attributes.lua'];
|
||||
matches = content.match(boolString);
|
||||
expect(matches).to.equal(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -56,6 +56,10 @@
|
||||
"ValidateArchitecture": {
|
||||
"src": "src/plugins/ValidateArchitecture",
|
||||
"test": "test/plugins/ValidateArchitecture"
|
||||
},
|
||||
"GenerateJob": {
|
||||
"src": "src/plugins/GenerateJob",
|
||||
"test": "test/plugins/GenerateJob"
|
||||
}
|
||||
},
|
||||
"layouts": {
|
||||
|
||||