Skip to content

Commit

Permalink
#63 response to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchuan2016 committed Aug 31, 2017
1 parent 5d85886 commit cfaec45
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 83 deletions.
3 changes: 0 additions & 3 deletions analysis/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ log.start_log(mode, vers)
env = Environment(ENV = {'PATH': os.environ['PATH']},
IMPLICIT_COMMAND_DEPENDENCIES = 0,
BUILDERS = {
# 'BuildLatex' : Builder(action = gs.build_latex),
'BuildLyx' : Builder(action = gs.build_lyx),
# 'BuildMatlab': Builder(action = gs.build_matlab),
'BuildPython': Builder(action = gs.build_python),
# 'BuildR' : Builder(action = gs.build_r),
# 'BuildStata' : Builder(action = gs.build_stata),
'Tablefill' : Builder(action = gs.build_tables)
})


Expand Down
3 changes: 3 additions & 0 deletions analysis/config_global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ build:
source:
prepare_data: source/prepare_data
descriptive: source/descriptive

# Switch to 'Yes' if it's required and 'No' if it's not.
prereq_git-lfs: Yes
4 changes: 2 additions & 2 deletions analysis/release/sconstruct.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*** New build: {2017-08-30 16:06:12} ***
*** New build: {2017-08-31 09:01:34} ***
scons: done reading SConscript files.
scons: Building targets ...
scons: `build' is up to date.
scons: `release' is up to date.
scons: done building targets.
*** Build completed: {2017-08-30 16:06:12} ***
*** Build completed: {2017-08-31 09:01:34} ***


55 changes: 31 additions & 24 deletions analysis/release/state_of_repo.log
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,76 @@ as it can be edited after state_of_repo.log finishes running
===================================
Last commit:

commit 465b8d9f106e4753bbe020d28d944c38128b1324
commit 5d85886f5a4b83fbe91cb9988373921cdbbba603
Author: chuanyu <yuchuan2016@gmail.com>
Date: Tue Aug 29 16:12:39 2017 -0700
Date: Wed Aug 30 16:07:40 2017 -0700

#63 add builder check
#63 add autimatic config scripts


Files changed since last commit:

analysis/release/descriptive/plot.eps
analysis/release/descriptive/sconscript_descriptive.log
analysis/SConstruct
analysis/config_global.yaml
analysis/release/sconstruct.log
analysis/release/state_of_repo.log
config/config_python.py
config/config_r.r
config/configuration.py
paper_slides/SConstruct
paper_slides/config_global.yaml
paper_slides/release/sconstruct.log
paper_slides/release/state_of_repo.log

===================================

FILE STATUS

===================================
./config_global.yaml:
modified on: 30 Aug 2017 13:28:40
size of file: 195
modified on: 31 Aug 2017 08:51:04
size of file: 273
./config_user.yaml:
modified on: 25 Aug 2017 11:06:38
size of file: 70
./SConstruct:
modified on: 30 Aug 2017 16:02:14
size of file: 2250
modified on: 31 Aug 2017 08:50:15
size of file: 2013
./sconstruct.log:
modified on: 30 Aug 2017 16:06:12
modified on: 31 Aug 2017 09:01:34
size of file: 199
./state_of_repo.log:
modified on: 30 Aug 2017 16:06:12
size of file: 576
modified on: 31 Aug 2017 09:01:34
size of file: 738
./build/descriptive/plot.eps:
modified on: 30 Aug 2017 16:06:06
modified on: 30 Aug 2017 16:56:33
size of file: 15385
./build/descriptive/sconscript_descriptive.log:
modified on: 30 Aug 2017 16:06:06
modified on: 30 Aug 2017 16:56:33
size of file: 99
./build/descriptive/table.txt:
modified on: 30 Aug 2017 16:06:06
modified on: 30 Aug 2017 16:56:33
size of file: 39
./build/prepare_data/data.txt:
modified on: 28 Aug 2017 09:58:31
modified on: 30 Aug 2017 16:56:32
size of file: 1988897
./build/prepare_data/sconscript_create_data.log:
modified on: 28 Aug 2017 09:58:31
modified on: 30 Aug 2017 16:56:32
size of file: 99
./release/sconstruct.log:
modified on: 30 Aug 2017 16:06:06
size of file: 692
modified on: 31 Aug 2017 08:42:35
size of file: 250
./release/state_of_repo.log:
modified on: 30 Aug 2017 16:06:06
size of file: 2737
modified on: 31 Aug 2017 08:42:34
size of file: 2744
./release/descriptive/plot.eps:
modified on: 30 Aug 2017 16:06:06
modified on: 31 Aug 2017 08:17:47
size of file: 15385
./release/descriptive/sconscript_descriptive.log:
modified on: 30 Aug 2017 16:06:06
modified on: 31 Aug 2017 08:17:47
size of file: 99
./release/descriptive/table.txt:
modified on: 30 Aug 2017 16:06:06
modified on: 30 Aug 2017 16:56:33
size of file: 39
./release/lg/data.txt:
modified on: 28 Aug 2017 09:58:31
Expand Down
9 changes: 6 additions & 3 deletions config/config_python.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import pip
import pkg_resources
# The collection of required packages.
# Packages with value True will be updated if it's already installed.
# Packages with value False will be skipped if it's already installed.
packages = {'pyyaml': True}

def main():
def main(packages):
# Install gslab_tools if it's not installed yet or it has the wrong version
if not check_gslab_tools('4.1.0'):
pip.main(['install', 'git+http://git@github.com/gslab-econ/gslab_python.git@4.1.0'])

# Install required packages using pip
packages = {'pyyaml': True}
installed_packages = [pkg.key for pkg in pip.get_installed_distributions()]
for pkg in packages.keys():
if pkg not in installed_packages or packages[pkg]:
Expand All @@ -31,4 +34,4 @@ def check_gslab_tools(gslab_python_version):
else:
return True

main()
main(packages)
13 changes: 8 additions & 5 deletions config/config_r.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Main <- function(){
CRAN_packages <- c("yaml", "ggplot2")
GitHub_packages <- NULL
# GitHub packages should be the full path to the relevant repo
# Required packages installed from CRAN.
CRAN_packages <- c("yaml")
# Required packages installed from Github. Should be the full path to the relevant repo.
GitHub_packages <- NULL

main <- function(CRAN_packages = NULL, GitHub_packages = NULL) {
# If there are packages installed from Github, first make sure "devtools" is installed
if (!is.null(GitHub_packages)) {
CRAN_packages <- c(CRAN_packages, "devtools")
}
Expand All @@ -25,4 +28,4 @@ install_CRAN <- function(pkg, repo, dependency, quiet){
}
}

Main()
main(CRAN_packages, GitHub_packages)
19 changes: 15 additions & 4 deletions config/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@
from gslab_scons import misc
from gslab_scons import configuration_tests as config

def configuration(ARGUMENTS, config_user_yaml = 'config_user.yaml'):
def configuration(ARGUMENTS, paper = False, config_user_yaml = 'config_user.yaml',
config_global_yaml = 'config_global.yaml'):
# Determines whether to print traceback messages
debug = ARGUMENTS.get('debug', False)
if not debug:
# Hide traceback for configuration test only
# http://stackoverflow.com/questions/27674602/hide-traceback-unless-a-debug-flag-is-set
sys.tracebacklimit = 0

# Checks git-lfs and lyx
config.check_lfs()
config.check_lyx()
# Checks git-lfs
prereq_gitlfs = misc.load_yaml_value(config_global_yaml, 'prereq_git-lfs')
if prereq_gitlfs:
config.check_lfs()

# Check lyx or latex
if paper:
prereq_lyx = misc.load_yaml_value(config_global_yaml, 'prereq_Lyx')
prereq_latex = misc.load_yaml_value(config_global_yaml, 'prereq_Latex')
if prereq_lyx:
config.check_lyx()
if prereq_latex:
pass

# Loads arguments and configurations
mode = ARGUMENTS.get('mode', 'develop') # Gets mode; defaults to 'develop'
Expand Down
26 changes: 14 additions & 12 deletions paper_slides/SConstruct
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# Preliminaries
import os
import sys
import atexit
import yaml
sys.path.append('../config')
sys.dont_write_bytecode = True # Don't write .pyc files

# Test for proper prerequisites and setup
from configuration_test import configuration_test
[mode, cache_dir] = configuration_test(ARGUMENTS, gslab_python_version = '4.1.0')
# Setup
from configuration import configuration
[mode, vers, cache_dir] = configuration(ARGUMENTS, paper = True)
import gslab_scons as gs
import gslab_scons.log as log
import yaml
import atexit
from gslab_scons import log
from gslab_scons import misc

# Start log after getting mode and release version
mode = ARGUMENTS.get('mode', 'develop')
vers = ARGUMENTS.get('version', '')
# Start log
log.start_log(mode, vers)

# Define the SCons environment
env = Environment(ENV = {'PATH': os.environ['PATH']},
IMPLICIT_COMMAND_DEPENDENCIES = 0,
BUILDERS = {'BuildLyx': Builder(action = gs.build_lyx),
'BuildLatex': Builder(action = gs.build_latex),
'Tablefill': Builder(action = gs.build_tables)})
BUILDERS = {
'BuildLyx': Builder(action = gs.build_lyx),
# 'BuildLatex': Builder(action = gs.build_latex),
'Tablefill': Builder(action = gs.build_tables),
})

# Only computes hash if time-stamp changed
env.Decider('MD5-timestamp')
Expand Down
2 changes: 1 addition & 1 deletion paper_slides/config_global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ source:
tables: source/tables
talk: source/talk

# Switch to 'Yes' if any of the following softwares are required
# Switch to 'Yes' if it's required and 'No' if it's not.
prereq_git-lfs: Yes
prereq_Latex: No
prereq_Lyx: Yes
4 changes: 2 additions & 2 deletions paper_slides/release/sconstruct.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*** New build: {2017-08-25 16:32:48} ***
*** New build: {2017-08-31 09:01:29} ***
scons: done reading SConscript files.
scons: Building targets ...
scons: `build' is up to date.
scons: `release' is up to date.
scons: done building targets.
*** Build completed: {2017-08-25 16:32:49} ***
*** Build completed: {2017-08-31 09:01:30} ***


Loading

0 comments on commit cfaec45

Please sign in to comment.