Project

General

Profile

AMI Eclipse Quick Start Guide » History » Revision 25

Revision 24 (Amber Herold, 01/29/2010 05:32 PM) → Revision 25/57 (Amber Herold, 01/29/2010 05:35 PM)

h1. AMI Eclipse Quick Start Guide 

 {{>toc}} 

 h2. 1 Get the Eclipse executable 

 # AMI has a preconfigured version available at [    ...    ] 
 # Copy it to ... 
 # Double click the eclipse executable to open. If using a machine that was setup with the AMI kickstart program, you will need to update [...] 

 h2. 2 Create a Workspace and get the MyAMI code from Subversion 

 # Double click the eclipse executable found in the eclipse directory. 
 # When it opens, it will prompt you to choose a workspace. This workspace will hold a local copy of the myami code for you to work on. A good workspace location is a amiworkspace in your home directory. That is /home/username/amiworkspace. 
 # From the menu, select Window -> Open Perspective -> SVN Repository Exploring. This will open a view labeled SVN Repositories. 
 # Go to File -> New -> Repository Location. 
 # In the URL field type: http://emg.nysbc.org/svn/myami to get the Appion and Leginon code. 
 # Press the Finish button at the bottom of the dialog. A new repository will appear in the SVN Repositories view. 
 # Click on the arrow next to the repository icon to view the trunk, branches and tags associated with the repository. 
 # Click on the trunk to highlight it. Right click and select Checkout. This will get the code from the repo and put it in your workspace. When the operation completes, you will find a myami directory under amiworkspace in your home directory. 

 h2. 3 Configure your Development Environment 

 There are 2 types of development that you will most often do with the MyAMI code, Python for core processing and PHP for the web interface. 
 
 h3. 1 Setup the Python environment 

 Go to Window -> Preferences -> PyDev -> Editor -> Interpreter – python. Press the Auto Config button then press OK. 

 h3. 2 Setup the PHP environment 

 There are two ways to view the web applications that you are developing in your home directory. If you are developing on a machine that does not have a local Apache server, you can use the Cronus3 web server. The advantage of this is that all the image processing plugins are already installed on Cronus3 so you don't have to worry about them and you don't have to worry about making Apache work. If you do run Apache locally, you can take advantage of integrated debugging tools in Eclipse and learn more about how all the pieces of the project fit together since will will have to set more things up.  

 Also note that the directions below will not get project_tools running. It is currently undergoing many changes and directions will be added when that process is complete. 

 h4. Use Cronus3 to view your web app 

 # Open a terminal and go to your home directory: @$ cd ~@ 
 # If is does not exist, create a directory called ami_html/: @$ mkdir ami_html/ 
 # Change directories to ami_html:    $cd ami_html@ 
 # Create a symbolic link to the web app directory in your workspace: @$ ln -s /home/[username]/amiworkspace/myami/myamiweb@ 
 # Try to browse to the project in a web browser ( http://cronus3/~username/myamiweb ). You should see an error because config.php failed to open. Keep reading "Create your config file" to fix this. 
  
 h4. Create your config file 
 
 *IMPORTANT:* Never check your local copy of the config files into Subversion. We don't want to share our database user information with the world. 

 # Change directories to the myamiweb project: $ cd ~/amiworkspace/myami/myamiweb 
 # Copy config.php.template to config.php: $ cp config.php.template config.php 
 # Open config.php for editting: $ vi config.php 
 # Make the following changes to config.php: 

 <pre> 
 // --- define dbem web tools base --- // 
 $BASE_PATH = "myamiweb"; 
 define('BASE_URL', "/".$BASE_PATH."/"); 

 // --- Set your leginon MySQL database server parameters 

 $DB_HOST          = "cronus4"; 
 $DB_USER          = "usr_object"; 
 $DB_PASS          = ""; 
 $DB               = "dbemdata"; 

 // --- XML test dataset 
 $XML_DATA = "test/viewerdata.xml"; 

 // --- Project database URL 

 $PROJECT_URL = "http://cronus3.scripps.edu/~[username]/project_tools"; 
 $PROJECT_DB_HOST = "cronus4"; 
 $PROJECT_DB_USER = "usr_object"; 
 $PROJECT_DB_PASS = ""; 
 $PROJECT_DB = "project"; 
 </pre> 

 Also modify config_processing.php: 

 <pre> 
 // --- Processing database --- // 
 $PROCESSING_DB_HOST = "cronus4"; 
 $PROCESSING_DB_USER = "usr_object"; 
 $PROCESSING_DB_PASS = ""; 
 $PROCESSING_DB = ""; //--- leave empty,    set by projectdb 


 // --- Add as many processing hosts as you like --- // 
 $PROCESSING_HOSTS[]="guppy"; 
 $PROCESSING_HOSTS[]=""; 
 </pre> 

 h4. Use your local Apache server to view your web app 

 # Make sure you are logged in as root. ($ su) 
 # Make sure Apache is installed. There should be /etc/init.d/httpd on your machine. Start apache with $ /etc/init.d/httpd start.  
 # Point a web browser to http://localhost/ and make sure you see the apache test page. 
 # Make sure Apache is configured for php 
 # the Apache config file is at /etc/httpd/conf 
 # web files should be at /var/www/html 
 ## create    symbolic link to your workspace in /var/www/html 
 ## Try to view at http://localhost/myamiweb  
 ## Not working because need the files on phpami 
 ### go to phpami in your myamiweb workspace and create symbolic links to each file that remove the .php file extension 
 ### put a symbolic link to this folder from user/share ( $ ln -s /home/amber/amiworkspace/myami/phpami php ) 
 # To debug PHP issues check http://localhost/myamiweb/info.php 
 # For everything to work, you need to install plugins like the MRC module 

 h2. 4 Get a local copy of the databases 

 If you want to work on the databases and you would prefer to have a local copy to play with, read [[SetupLocalDB | How to set up spend a local copy couple of AMI databases]]. hours doing the following: 

 h3. 1 Make sure MySQL is installed 

 Follow the instructions in the "Leginon install guide":http://emg.nysbc.org/documentation/leginon/bk02ch04s07.php. 
 
 Also install phpMyAdmin found under "Other Tools" on "this page":http://emg.nysbc.org/documentation/leginon/bk02ch04s08.php. 
 Note that phpMyAdmin version 2.11.10 works with older versions of PHP (that we happen to use). 

 h3. 2 Dump tables from cronus4 to a local file 

 This will grab the actual data that we use so you can play with it. 
 Log into cronus3 so that you can access cronus4. 

 <pre> 
 $ ssh cronus3 
 </pre> 

 Use mysqldump to get any table data that you want as in the example below.  
 Cronus4 is the host.  
 We do not lock the tables because we don't have permission to.  
 "project" is the name of the database and "login" is the name of the Table. 
 We make up a file name for the data to dump to. 

 <pre> 
 $ mysqldump -h cronus4 -u usr_object --skip-lock-tables project login > ProjectLogin.sql 
 </pre> 

 Exit cronus3 when you are done dumping tables and load the dump files into your database. 
 If you followed the instructions for setting up MySQL in the Leginon Install guide, you have already created dbemdata and projectdata databases. 
 If you don't have them, create them first. 

 <pre> 
 mysql -u root projectdata < ProjectLogin.sql 
 </pre> 

 h3. 3 Modify Config.php 

 It should look like this: 

 <pre> 
 // --- Set your leginon MySQL database server parameters 

 $DB_HOST          = "localhost"; 
 $DB_USER          = "usr_object"; 
 $DB_PASS          = ""; 
 $DB               = "dbemdata"; 

 // --- XML test dataset 
 $XML_DATA = "test/viewerdata.xml"; 

 // --- Project database URL 

 $PROJECT_URL = "project"; 
 $PROJECT_DB_HOST = "localhost"; 
 $PROJECT_DB_USER = "usr_object"; 
 $PROJECT_DB_PASS = ""; 
 $PROJECT_DB = "projectdata"; 
 </pre> 

 h3. 4 Populate your databases automagically 

 Point your web browser to http://localhost/myamiweb/. 
 Navigate to the Administration page and then to the ProjectDB page.  

 Doing this will populate your database with the schema defined in myami/myamiweb/project/defaultprojecttables.xml.