Skip to content

Commit

Permalink
Revert "PR #21: Review and test template (#25)"
Browse files Browse the repository at this point in the history
This reverts commit 5f1d277.
  • Loading branch information
z-y-huang authored Aug 13, 2019
1 parent 5f1d277 commit d72c23f
Show file tree
Hide file tree
Showing 50 changed files with 608 additions and 990 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*.lyx.emergency
*.Rhistory
*.Rapp.history
*Rplots.pdf
*.DS_Store
*.aux
*.fls
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To build the repository as-is, the following applications are additionally requi
* R
* Stata

These software are used by the scripts contained in the repository. By default, the **Setup** and **Build** instructions below will assume their usage.
These software are used by the scripts contained in the repository. By default, the **Setup** instructions below will assume their usage.

## Setup
**If you are using Windows, you may need to run certain bash commands in administrator mode due to permission errors. To do so, open your terminal by right clicking and selecting `Run as administrator`. To set administrator mode on permanently, refer to the [RA manual](https://github.com/gentzkow/template/wiki/Repository-Usage#Administrator-Mode).**
Expand Down Expand Up @@ -51,16 +51,6 @@ These software are used by the scripts contained in the repository. By default,
Rscript setup_r.r
```

## Build
**If you are using Windows, you may need to run certain bash commands in administrator mode due to permission errors. To do so, open your terminal by right clicking and selecting `Run as administrator`. To set administrator mode on permanently, refer to the [RA manual](https://github.com/gentzkow/template/wiki/Repository-Usage#Administrator-Mode).**

1. Follow the *Setup* instructions above.

2. From the root of repository, run the following bash command:
```
python run_all.py
```

## Command Line Usage

For specific instructions on how to set up command line usage for an application, refer to the [RA manual](https://github.com/gentzkow/template/wiki/Command-Line-Usage).
Expand Down
17 changes: 0 additions & 17 deletions analysis/external.txt

This file was deleted.

17 changes: 17 additions & 0 deletions analysis/externals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Each line of instruction in this `externals.txt` file should contain a destination and source delimited by a `|`.
# Lines beginning with # are ignored.
#
# For example, suppose your `externals.txt` file contains the following lines of text:
# > destination | source
#
# Now suppose you run the following line of code:
# > link_externals(paths, ['externals.txt'])
#
# This will create a link in `paths['external_dir']` named `destination` that links to `source`.
#
# Alternative, suppose you run the following line of code:
# > copy_externals(paths, ['externals.txt'])
#
# This will create a file in `paths['eternal_dir']` named `destination` that is a copy of `source`.

# Destination | Source
File renamed without changes.
7 changes: 5 additions & 2 deletions analysis/log/make.log
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
--------------------------------------------------------------------------------
Makelog started: 2019-07-29 17:06:01
Makelog started: 2019-05-08 12:19:30
Working directory: /Users/zong/template/analysis
--------------------------------------------------------------------------------
Input links successfully created!
External links successfully created!
Source logs successfully written!
WARNING! The following target files have been modified according to git status:
/Users/zong/template/data/output/data_graph.csv
/Users/zong/template/data/output/data_table.csv
Executing command: `python "/Users/zong/template/analysis/code/descriptive.py" `
Output logs successfully written!
--------------------------------------------------------------------------------
Makelog ended: 2019-07-29 17:06:04
Makelog ended: 2019-05-08 12:19:33
Working directory: /Users/zong/template/analysis
--------------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion analysis/log/output_heads.log
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ File headers
%!PS-Adobe-3.0 EPSF-3.0
%%Title: output/plot.eps
%%Creator: matplotlib version 2.2.3, http://matplotlib.org/
%%CreationDate: Mon Jul 29 17:06:03 2019
%%CreationDate: Wed May 8 12:19:32 2019
%%Orientation: portrait
%%BoundingBox: 75 223 536 568
%%EndComments
Expand Down
6 changes: 3 additions & 3 deletions analysis/log/output_stats.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file name | last modified | file size
/Users/zong/template/analysis/output/plot.eps | 2019-07-30 00:06:03 | 13305
/Users/zong/template/analysis/output/tables.txt | 2019-07-30 00:06:04 | 40
file name last modified file size
/Users/zong/template/analysis/output/plot.eps 2019-05-08 19:19:32 13305
/Users/zong/template/analysis/output/tables.txt 2019-05-08 19:19:33 40
6 changes: 3 additions & 3 deletions analysis/log/source_stats.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file name | last modified | file size
/Users/zong/template/data/output/data_graph.csv | 2019-07-30 00:06:00 | 2044452
/Users/zong/template/data/output/data_table.csv | 2019-07-30 00:05:59 | 2044448
file name last modified file size
/Users/zong/template/data/output/data_graph.csv 2019-05-08 19:17:55 2044452
/Users/zong/template/data/output/data_table.csv 2019-05-08 19:17:54 2044448
36 changes: 15 additions & 21 deletions analysis/make.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
###################
### ENVIRONMENT ###
###################
### ENVIRONMENT
import git
import imp
import os
import yaml

# LOAD GSLAB MAKE
ROOT = git.Repo('.', search_parent_directories = True).working_tree_dir
f, path, desc = imp.find_module('gslab_make', [os.path.join(ROOT, 'lib')])
gs = imp.load_module('gslab_make', f, path, desc)
gs = imp.load_module('gslab_make', f, path, desc) # Load `gslab_make`

# SET DEFAULT PATHS
PATHS = {
PATHS = { # Set default paths; used by `gslab_make` functions
'config' : '../config.yaml',
'config_user' : '../config_user.yaml',
'input_dir' : 'input',
'external_dir' : 'external',
'output_dir' : 'output/',
'output_local_dir': ['output_local'], # Optional; include any local directories with outputs
'output_local_dir': [], # Optional; include any local directories with outputs
'pdf_dir' : 'output/',
'makelog' : 'log/make.log', # Set to '' to avoid writing log
'output_statslog' : 'log/output_stats.log', # Set to '' to avoid writing log
Expand All @@ -28,27 +24,25 @@
'source_headslog' : 'log/source_heads.log' # Set to '' to avoid writing log
}

### SET PATH MAPPINGS
PATH_MAPPINGS = {
PATH_MAPPINGS = { # Set path mappings; used by `move_sources` functions
'root': ROOT
}

### LOAD CONFIG USER
gs.update_executables(PATHS)
PATH_MAPPINGS = gs.update_mappings(PATHS, PATH_MAPPINGS)
### CONFIG USER
config_user = yaml.load(open(PATHS['config_user'], 'rb'))
if config_user['local']['executables']: # Update executables; used by `run_program` functions
gs.private.metadata.default_executables[os.name].update(config_user['local']['executables'])
if config_user['external']: # Update path mappings; used by `create_links` functions
PATH_MAPPINGS.update(config_user['external'])

############
### MAKE ###
############

### START MAKE
### START
gs.remove_dir(['input', 'external'])
gs.clear_dir(['output', 'log'])
gs.start_makelog(PATHS)

### GET INPUT FILES
inputs = gs.link_inputs(PATHS, ['input.txt'], PATH_MAPPINGS)
externals = gs.link_externals(PATHS, ['external.txt'], PATH_MAPPINGS)
inputs = gs.link_inputs(PATHS, ['inputs.txt'], PATH_MAPPINGS)
externals = gs.link_externals(PATHS, ['externals.txt'], PATH_MAPPINGS)
gs.write_source_logs(PATHS, inputs + externals)
gs.get_modified_sources(PATHS, inputs + externals)

Expand All @@ -61,5 +55,5 @@
### CHECK FILE SIZES
gs.check_module_size(PATHS)

### END MAKE
### END
gs.end_makelog(PATHS)
2 changes: 1 addition & 1 deletion analysis/output/plot.eps

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ software_required:
# Maximum allowed file sizes
#####################################################################
max_file_sizes:
file_MB_limit_lfs: 100 # Soft limit on file size (w/ LFS)
total_MB_limit_lfs: 500 # Soft limit on total size (w/ LFS)
file_MB_limit: 0.5 # Soft limit on file size (w/o LFS)
total_MB_limit: 100 # Soft limit on total size (w/o LFS)
file_MB_limit_lfs: 100 # Soft limit on file size (w/ LFS)
total_MB_limit_lfs: 500 # Soft limit on total size (w/ LFS)
file_MB_limit: 0.5 # Soft limit on file size (w/o LFS)
total_MB_limit: 100 # Soft limit on total size (w/o LFS)


17 changes: 0 additions & 17 deletions data/external.txt

This file was deleted.

17 changes: 17 additions & 0 deletions data/externals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Each line of instruction in this `externals.txt` file should contain a destination and source delimited by a `|`.
# Lines beginning with # are ignored.
#
# For example, suppose your `externals.txt` file contains the following lines of text:
# > destination | source
#
# Now suppose you run the following line of code:
# > link_externals(paths, ['externals.txt'])
#
# This will create a link in `paths['external_dir']` named `destination` that links to `source`.
#
# Alternative, suppose you run the following line of code:
# > copy_externals(paths, ['externals.txt'])
#
# This will create a file in `paths['eternal_dir']` named `destination` that is a copy of `source`.

# Destination | Source
File renamed without changes.
8 changes: 4 additions & 4 deletions data/log/make.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------------
Makelog started: 2019-07-29 17:05:58
Makelog started: 2019-05-08 12:17:53
Working directory: /Users/zong/template/data
--------------------------------------------------------------------------------
Input links successfully created!
Expand All @@ -17,8 +17,8 @@ ___/ / /___/ / /___/ 15.1 Copyright 1985-2017 StataCorp LLC
979-696-4600 stata@stata.com
979-696-4601 (fax)

Unlimited-user 4-core Stata network license expires 21 Jul 2020:
Serial number: 501609000313
Unlimited-user 4-core Stata network license expires 21 Jul 2019:
Serial number: 501509201134
Licensed to: Zong Huang
Stanford University

Expand Down Expand Up @@ -54,6 +54,6 @@ end of do-file

Output logs successfully written!
--------------------------------------------------------------------------------
Makelog ended: 2019-07-29 17:06:00
Makelog ended: 2019-05-08 12:17:55
Working directory: /Users/zong/template/data
--------------------------------------------------------------------------------
6 changes: 3 additions & 3 deletions data/log/output_stats.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file name | last modified | file size
/Users/zong/template/data/output/data_graph.csv | 2019-07-30 00:06:00 | 2044452
/Users/zong/template/data/output/data_table.csv | 2019-07-30 00:05:59 | 2044448
file name last modified file size
/Users/zong/template/data/output/data_graph.csv 2019-05-08 19:17:55 2044452
/Users/zong/template/data/output/data_table.csv 2019-05-08 19:17:54 2044448
4 changes: 2 additions & 2 deletions data/log/source_stats.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
file name | last modified | file size
/Users/zong/template/raw/data.csv | 2019-07-12 17:24:17 | 1988897
file name last modified file size
/Users/zong/template/raw/data.csv 2019-05-07 19:45:55 1988897
36 changes: 15 additions & 21 deletions data/make.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
###################
### ENVIRONMENT ###
###################
### ENVIRONMENT
import git
import imp
import os
import yaml

# LOAD GSLAB MAKE
ROOT = git.Repo('.', search_parent_directories = True).working_tree_dir
f, path, desc = imp.find_module('gslab_make', [os.path.join(ROOT, 'lib')])
gs = imp.load_module('gslab_make', f, path, desc)
gs = imp.load_module('gslab_make', f, path, desc) # Load `gslab_make`

# SET DEFAULT PATHS
PATHS = {
PATHS = { # Set default paths; used by `gslab_make` functions
'config' : '../config.yaml',
'config_user' : '../config_user.yaml',
'input_dir' : 'input',
'external_dir' : 'external',
'output_dir' : 'output/',
'output_local_dir': ['output_local'], # Optional; include any local directories with outputs
'output_local_dir': [], # Optional; include any local directories with outputs
'pdf_dir' : 'output/',
'makelog' : 'log/make.log', # Set to '' to avoid writing log
'output_statslog' : 'log/output_stats.log', # Set to '' to avoid writing log
Expand All @@ -28,27 +24,25 @@
'source_headslog' : 'log/source_heads.log' # Set to '' to avoid writing log
}

### SET PATH MAPPINGS
PATH_MAPPINGS = {
PATH_MAPPINGS = { # Set path mappings; used by `move_sources` functions
'root': ROOT
}

### LOAD CONFIG USER
gs.update_executables(PATHS)
PATH_MAPPINGS = gs.update_mappings(PATHS, PATH_MAPPINGS)
### CONFIG USER
config_user = yaml.load(open(PATHS['config_user'], 'rb'))
if config_user['local']['executables']: # Update executables; used by `run_program` functions
gs.private.metadata.default_executables[os.name].update(config_user['local']['executables'])
if config_user['external']: # Update path mappings; used by `create_links` functions
PATH_MAPPINGS.update(config_user['external'])

############
### MAKE ###
############

### START MAKE
### START
gs.remove_dir(['input', 'external'])
gs.clear_dir(['output', 'log'])
gs.start_makelog(PATHS)

### GET INPUT FILES
inputs = gs.link_inputs(PATHS, ['input.txt'], PATH_MAPPINGS)
externals = gs.link_externals(PATHS, ['external.txt'], PATH_MAPPINGS)
inputs = gs.link_inputs(PATHS, ['inputs.txt'], PATH_MAPPINGS)
externals = gs.link_externals(PATHS, ['externals.txt'], PATH_MAPPINGS)
gs.write_source_logs(PATHS, inputs + externals)
gs.get_modified_sources(PATHS, inputs + externals)

Expand All @@ -62,5 +56,5 @@
### CHECK FILE SIZES
gs.check_module_size(PATHS)

### END MAKE
### END
gs.end_makelog(PATHS)
Loading

0 comments on commit d72c23f

Please sign in to comment.