![]() |
Page History
...
Install Python 2.7. For current Debian-based Linux distributions (such as Ubuntu), BSD and Mac Python 2.7 is usually installed. However Redhat-based Linux distributions, such as RHEL and CentOS, are sometimes behind the curve and do not have Python 2.7. As of this writing, CentOS 6.4 is at Python 2.6, which is well on its way to EOL. Python 2.6 may work, but code will be written with 2.7 and 3.3+ in mind. Below are instructions for Ubuntu Linux 13.04+.
sudo apt-get install python2.7 python2.7-dev python-virtualenv
Install PIP.
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include sudo apt-get install python-pip
Install virtualenv.
sudo apt-get install python-virtualenv
Install Git.
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include sudo apt-get install git
Install the prerequisites for MySQL-Python.
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include sudo apt-get install build-essential python-dev libmysqlclient-dev
...
For more details and recommended practices, see Developer Guidelines.
Multiexcerpt include | ||||||
---|---|---|---|---|---|---|
|
Configure Your Local Environment
...
Run the dev_setup script.
Windows
cd codalab .\dev_setup.bat
If you are going to use SQL Server as a database, you will need to install the Python PyODBC library
. Before runningMultiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include dev_setup
, you can download the installer, then run the setup script as follows (assuming the installer was downloaded at the root of a D drive):cd codalab dev_setup.bat D:\pyodbc-3.0.7.win-amd64-py2.7.exe
Linux
cd codalab source ./dev_setup.sh
Activate the virtual environment.
Windows
venv\Scripts\activate
Linux
source venv/bin/activate
...
- Open your local configuration file (
local.py
). If there is nolocal.py
, save a copy oflocal_sample.py
namedlocal.py
in the same directory. In the
Azure storage
section, enter your Azure account details:Code Block DEFAULT_FILE_STORAGE = 'codalab.azure_storage.AzureStorage' AZURE_ACCOUNT_NAME = "<enter name>" AZURE_ACCOUNT_KEY = '<enter key>' AZURE_CONTAINER = '<enter container name>' PRIVATE_FILE_STORAGE = 'codalab.azure_storage.AzureStorage' PRIVATE_AZURE_ACCOUNT_NAME = "<enter name>" PRIVATE_AZURE_ACCOUNT_KEY = "<enter key>" PRIVATE_AZURE_CONTAINER = "<enter container name>" BUNDLE_AZURE_CONTAINER = "<enter the name of your bundle container>" BUNDLE_AZURE_ACCOUNT_NAME = PRIVATE_AZURE_ACCOUNT_NAME BUNDLE_AZURE_ACCOUNT_KEY = PRIVATE_AZURE_ACCOUNT_KEY
In the
Service Bus
section, enter your service bus connection information:Code Block SBS_NAMESPACE = '<enter the name of your service bus>' SBS_ISSUER = 'owner' SBS_ACCOUNT_KEY = '<enter value for 'default key'>'
Note title Important Do not change the values for
DEFAULT_FILE_STORAGE
andPRIVATE_FILE_STORAGE
, as these parameters contain the name of the Python class which implements the Azure storage back-end for Django.In the
DATABASES
section, enter the configuration settings for the database you want to use.SQL Server*
Code Block DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'somename', # Leaver user and password blank to use integrated security 'USER': '', 'PASSWORD': '', 'HOST': '(localdb)\\v11.0', 'PORT': '', 'OPTIONS': { 'driver': 'SQL Server Native Client 11.0', } }
MySQL
Code Block DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'MySQL_DevDB', 'USER': 'someuser', 'PASSWORD': 'somepassword', 'HOST': 'someserver', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 'PORT': '', # Set to empty string for default. }
...
Make sure you have a valid management certificate to connect to the Service Management endpoint. This tutorial explains how to create a certificate and upload it to the Azure management portal: http://azure.microsoft.com/en-us/documentation/articles/cloud-services-python-how-to-use-service-management/
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include Open
codalab/codalabtools/compute/enableCORS.py
in a text editor, and updateaccount_name
andaccount_key
with the account name and key for your blob storage account:Code Block import sys import yaml from os.path import dirname, abspath # Add codalabtools to the module search path sys.path.append(dirname(dirname(abspath(__file__)))) from codalabtools.azure_extensions import (Cors,CorsRule,set_storage_service_cors_properties) account_name = "<your blob storage account name>" account_key = "<your blob storage account key>" cors_rule = CorsRule() cors_rule.allowed_origins = '*' # this is fine for dev setup cors_rule.allowed_methods = 'PUT' cors_rule.exposed_headers = '*' cors_rule.allowed_headers = '*' cors_rule.max_age_in_seconds = 1800 cors_rules = Cors() cors_rules.cors_rule.append(cors_rule) set_storage_service_cors_properties(account_name, account_key, cors_rules)
Save your changes, activate your virtual environment and run the script:
Windows
python scripts\cors-enable.py
Linux
python scripts/cors-enable.py
Initialize the Database
To initialize the database, you will need to run a few standard Django commands
Multiexcerpt include | ||||||
---|---|---|---|---|---|---|
|
...
You can already run the Django web site on your local machine as described on this page
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include You have also forked the codalab-cli
project and have gone through the steps listed in the ReadmeMultiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include
.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include
With those assumptions in place:
...
Use the following command to start the CodaLab server locally.
python manage.py runserver
Open a browser and navigate to http://127.0.0.1:8000
to preview the site.Multiexcerpt include nopanel true MultiExcerptName ExitDisclaimer PageWithExcerpt wikicontent:Exit Disclaimer to Include When your next coding session comes along, remember to work in the virtual environment you created:
Windows
venv\Scripts\activate
Linux
source venv/bin/activate
Note: If you experience database errors try deleting the database file (\codalab\codalab\dev_db.*) and run syncdb again. After creating a new database be sure to run initialize.py
in the scripts
folder in order to insert initial data required by the app.
...
- Open a command prompt and activate your CodaLab virtual environment.
Start the first compute worker as shown here:
cd codalab python worker.py
Open a second command prompt and activate your CodaLab virtual environment.
Start the second compute worker as shown here:
cd codalabtools\compute python worker.py
If you plan to test competitions locally, open a third command prompt and activate the virtual environment for the CodaLab CLI, then start the bundle server:
cl server