Skip to content

Commit

Permalink
Merge 32a3790 into 37bd54d
Browse files Browse the repository at this point in the history
  • Loading branch information
Caffetaria committed Nov 29, 2018
2 parents 37bd54d + 32a3790 commit 4a0e155
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 79 deletions.
191 changes: 130 additions & 61 deletions Origami/src/components/user/nonghUserProfile.js
Expand Up @@ -38,8 +38,18 @@ class NonGHUserProfileComponent extends React.Component {
showDataModal: false,
permalinkHolder: {},
projectBeingDeletedId: "",
demoLoading: true
demoLoading: true,


modifiedDemoName: "",
modifiedDemoDescription: "",
modifiedDemoPython: "1",
modifiedDemoCuda: "1",
modifiedDemoOS: "1",
modifiedDemoSourceCode: ""

};

this.socket = this.context.socket;
this.success = this.success.bind(this);
this.initiateLogin = this.initiateLogin.bind(this);
Expand All @@ -54,6 +64,14 @@ class NonGHUserProfileComponent extends React.Component {
);
this.toggleShowDataDialog = this.toggleShowDataDialog.bind(this);
this.getStyles = this.getStyles.bind(this);


this.modifyDemoName = this.modifyDemoName.bind(this);
this.modifyDemoDescription = this.modifyDemoDescription.bind(this);
this.modifyDemoPython = this.modifyDemoPython.bind(this);
this.modifyDemoCuda = this.modifyDemoCuda.bind(this);
this.modifyDemoOS = this.modifyDemoOS.bind(this);
this.modifyDemoSourceCode = this.modifyDemoSourceCode.bind(this);
}

componentWillMount() {
Expand Down Expand Up @@ -125,7 +143,6 @@ class NonGHUserProfileComponent extends React.Component {
}

deleteDemo() {
console.log("aaya");
const project_id = this.state.projectBeingDeletedId;
this.toggleDeleteConfirmationDialog();
this.props.nonghModelActions
Expand All @@ -146,25 +163,41 @@ class NonGHUserProfileComponent extends React.Component {
});
}

modifyProject(project) {
let dataToUpdate = {
name: project.name,
id: project.id,
user_id: project.user_id,
description: project.description,
timestamp: project.timestamp,
token: project.token,
status: project.status,
appData: {}
};
this.props.nonghModelActions.updateNonGHDemoModel(dataToUpdate).then(() => {
this.setState({ projectBeingEdited: project }, () => {
modifyProject() {

let dataToUpdate = this.state.projectBeingEdited;
dataToUpdate.name = (this.state.modifiedDemoName===""?dataToUpdate.name:this.state.modifiedDemoName);
dataToUpdate.description = (this.state.modifiedDemoDescription===""?dataToUpdate.description:this.state.modifiedDemoDescription);
dataToUpdate.python =(this.state.modifiedDemoPython==="1"?1:2);
dataToUpdate.cuda = (this.state.modifiedDemoCuda.includes("1")?1:2);
dataToUpdate.os=(this.state.modifiedDemoOS.includes("1")?1:2);
dataToUpdate.source_code= (this.state.modifiedDemoSourceCode===""?dataToUpdate.source_code:this.state.modifiedDemoSourceCode);
console.log('this is the updated object now', dataToUpdate);
this.props.nonghModelActions.addToDBNonGHDemoModel(dataToUpdate)
.then(() => this.props.nonghModelActions.updateNonGHDemoModel(dataToUpdate))
.then(() => {
this.toggleModifyDialog();
});
this.props.history.push(
`/instructions/${dataToUpdate.user_id}/${dataToUpdate.id}/bundle`
);
});
}

toggleModifyDialog() {
toggleModifyDialog(demoBeingModified) {
if(demoBeingModified){

demoBeingModified.python = (demoBeingModified.python.includes("1")?"1":"2");
demoBeingModified.cuda = (demoBeingModified.cuda.includes("1")?"1":"2");
demoBeingModified.os = (demoBeingModified.os.includes("1")?"1":"2");

this.setState({projectBeingEdited: demoBeingModified});


} else {
this.setState({projectBeingEdited: {}})
}


this.setState({ showModifyModal: !this.state.showModifyModal });
}

Expand All @@ -184,6 +217,7 @@ class NonGHUserProfileComponent extends React.Component {
}
}


goToDemoPage(project) {
this.props.history.push(
`/ngh/user/${this.props.user.id}/${project.name}/${project.id}/demo`
Expand Down Expand Up @@ -223,6 +257,33 @@ class NonGHUserProfileComponent extends React.Component {
};
}


modifyDemoName(e){
this.setState({modifiedDemoName: e.target.value});
}


modifyDemoDescription(e){
this.setState({modifiedDemoDescription: e.target.value});
}



modifyDemoPython(e){
this.setState({modifiedDemoPython: e.target.value});
}

modifyDemoCuda(e){
this.setState({modifiedDemoCuda: e.target.value});
}

modifyDemoOS(e){
this.setState({modifiedDemoOS: e.target.value});
}

modifyDemoSourceCode(e){
this.setState({modifiedDemoSourceCode: e.target.value});
}
render() {
const demoSpinnerStyle = {
position: "fixed",
Expand Down Expand Up @@ -309,9 +370,18 @@ class NonGHUserProfileComponent extends React.Component {
color: "#323643",
backgroundColor: "White"
}}
onClick={() =>

{
console.log('this is the unaltered demo obj', demo);
this.toggleModifyDialog(demo);}
}
>
Modify
Modify <br/>

</button>


<button
className="ui button"
style={{
Expand Down Expand Up @@ -361,51 +431,50 @@ class NonGHUserProfileComponent extends React.Component {
title="Modify Application"
open={this.state.showModifyModal}
onRequestClose={this.toggleModifyDialog}
contentStyle={{ width: "30%" }}
>
<div className="ui stackable grid">
<div className="ui stackable row">
<div className="center aligned six wide column">
<RaisedButton
label="Metadata"
primary
onTouchTap={() =>
this.props.history.push(
`/ngh/user/${this.state.projectBeingEdited.name}/${
this.state.projectBeingEdited.id
}/register/modify`
)
}
/>
</div>
<div className="center aligned five wide column">
<RaisedButton
label="Input"
primary
onTouchTap={() =>
this.props.history.push(
`/ngh/user/${this.state.projectBeingEdited.name}/${
this.state.projectBeingEdited.id
}/inputcomponent/modify`
)
}
/>
</div>
<div className="center aligned five wide column">
<RaisedButton
label="Output"
primary
onTouchTap={() =>
this.props.history.push(
`/ngh/user/${this.state.projectBeingEdited.name}/${
this.state.projectBeingEdited.id
}/outputcomponent/modify`
)
}
/>
</div>
<div>
Task type is: {this.state.projectBeingEdited.task} and cannot be edited <br/>
<table>
<tr><th>Data Type</th><th>Data</th></tr>
<tr><td>Appname</td>
<td><input type = "text" defaultValue = {this.state.projectBeingEdited.name} onChange={this.modifyDemoName}/> <br/></td></tr>
<tr><td>Description</td>
<td><input type = "text" defaultValue = {this.state.projectBeingEdited.description} onChange={this.modifyDemoDescription} /> <br/></td></tr>

<tr><td>Python</td><td>
<select defaultValue={this.state.projectBeingEdited.python} onChange={this.modifyDemoPython}>
<option value="1">Python 2.7</option>
<option value="2">Python 3.5</option>
</select>
<br/></td></tr>
<tr><td>CUDA</td><td>
<select defaultValue={this.state.projectBeingEdited.cuda} onChange={this.modifyDemoCuda}>
<option value="1">CUDA 7.0</option>
<option value="2">CUDA 8.0</option>
</select>
<br/></td></tr>
<tr><td>Ubuntu</td><td>
<select defaultValue={this.state.projectBeingEdited.os} onChange={this.modifyDemoOS}>
<option value="1">Ubuntu 14.04</option>
<option value="2">Ubuntu 16.04</option>
</select>
<br/>
</td></tr><tr><td>Source code</td><td>
<input type = "text" defaultValue = {this.state.projectBeingEdited.source_code} onChange = {this.modifyDemoSourceCode} /> <br/>
<br/>
<br/>
</td></tr>
</table>



<button type="button" onClick={() =>
{
this.modifyProject();
}
}>Click Me to modify!</button>
</div>
</div>

</Dialog>

<Dialog
Expand Down
47 changes: 29 additions & 18 deletions README.md
Expand Up @@ -21,21 +21,30 @@
<p align="center"><img width="80%" height="60%" src="origami.png" /></p>
<h4 align="center">Artificial Intelligence as a Service</h4>

- Origami is an AI-as-a-service that allows researchers to easily convert their deep learning models into an online service that is widely accessible to everyone without the need to setup the infrastructure, resolve the dependencies, and build a web service around the deep learning model. By lowering the barrier to entry to latest AI algorithms, we provide developers, researchers and students the ability to access any model using a simple REST API call.
- Origami is an AI-as-a-service that allows researchers to easily convert their deep learning models into an online service that is widely accessible to everyone without the need
to setup the infrastructure, resolve the dependencies, and build a web service around the deep learning model. By lowering the barrier to entry to latest AI algorithms, we provide developers, researchers and students the ability to access any model using a simple REST API call.

- The aim of this project is to create a framework that can help people create a web based demo out of their machine learning code and share it. Others can test the model without going into the implementation details. Usually testing models by other people involves a lot of preparation and setup. This project aims to cut that down.


This app is presently under active development and we welcome contributions. Please check out our [issues thread](https://github.com/Cloud-CV/Origami/issues) to find things to work on, or ping us on [Gitter](https://gitter.im/Cloud-CV/Origami).

## Installation Instructions

### Requirements before installation
Before you start on the installation of Origami, ensure that you have the following installed on your computer-
1. PostgreSQL 10.5 or later
2. Python 2.7/3.4
3. Docker
4. Node v5+
5. Yarn (for package management)
### Setting the environment variables

* `origami.env` stores all the environment variables necessary to run Origami.

1. `HOST` should be set to the hostname of the server
2. `PORT` should be set to the port you want the server to listen on. (Generally 80)
2. `PORT` should be set to the port you want the server to listen on.
(Generally 8000)
Perform steps 3, 4, 5 and 6 after setting up the database.
3. `DB_NAME` will be used to set the name for your postgres database
4. `DB_PASS` will be used to set the password for the database user. This is also the admin password
5. `DB_USER` is the username for a user who can modify the database. This is also the admin username
Expand All @@ -47,24 +56,18 @@ To create the file, `cp origami.env.sample origami.env` and edit the file with t

* `Origami/outCalls/config.js` stores config variables needed by the UI.

The following variables are set up correctly by default and do not need to be changed:
1. `CLIENT_IP` should be set to the same value as `HOST` in `origami.env`
2. `CLIENT_PORT` should be set to the same value as `PORT` in `origami.env`
3. For `DROPBOX_API_KEY` , check step 3 of [configuring Origami](http://cloudcv-origami.readthedocs.io/en/latest/web-app.html#configuration)

## Production setup instructions

**Use docker to setup Origami on production**

### Running the server

You can run the server with the help of docker and docker-compose.

You can run the server with the help of docker and docker-compose
Run `docker-compose up`

## Development setup instructions

**This application requires node v5+ and Python 2.7/3.4+**

### Create a Virtual Environment

1. `pip install virtualenv`
Expand Down Expand Up @@ -93,18 +96,20 @@ Run `docker-compose up`
`source origami.env`

### Setting up the database

#### Create all the tables
1. Create a user and set the password for that user.
2. Add the CREATEDB permission to your new user.
3. Create a database
4. Create admin account
`python manage.py initadmin`
5. Grant privileges to the admin account by using the command-
`GRANT ALL PRIVILEGES ON DATABASE database_name TO user; postgres=> \list`
6. Create all the tables

```
python manage.py makemigrations
python manage.py migrate
```

#### Create admin account

`python manage.py initadmin`


### Start the server

1. Start the server by `python manage.py runserver --noworker`
Expand All @@ -113,6 +118,10 @@ python manage.py migrate
4. Go to [localhost:8000](http://localhost:8000/)
Visit [Read the docs](http://cloudcv-origami.readthedocs.io/en/latest/) for further instructions on Getting started

## Production setup instructions

**Use docker to setup Origami on production**

## Contributing to Origami

1. Make sure your run tests on your changes before you push the code using:
Expand All @@ -125,3 +134,5 @@ python manage.py migrate
## License

This software is licensed under GNU AGPLv3. Please see the included `License` file. All external libraries, if modified, will be mentioned below explicitly.


0 comments on commit 4a0e155

Please sign in to comment.