Skip to content

Commit

Permalink
Removed all sources. Replaced with a simple manifest. Replaced build-…
Browse files Browse the repository at this point in the history
…labs.sh with a Python program (build-labs).
  • Loading branch information
bmc committed Jul 21, 2016
1 parent f0a82af commit 6e58f30
Show file tree
Hide file tree
Showing 33 changed files with 188 additions and 11,418 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tmp
136 changes: 136 additions & 0 deletions build-labs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#!/usr/bin/env python

import sys
import os
import shutil
from subprocess import call as call_process

TMP_DIR = "tmp"
BUILD_DIR = os.path.join(TMP_DIR, "build_mp")
COPY_DIR = os.path.join(TMP_DIR, "copy")

def die(msg):
sys.stderr.write(msg + "\n")
sys.exit(1)

def find_in_path(executable):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, executable)
if is_exe(exe_file):
return exe_file

return None

def sh(cmd):
try:
print ' '.join(cmd)
rc = call_process(cmd)
if rc != 0:
raise OSError('Command failed.')
except OSError as e:
raise Exception(
'Failed to run {0}: {1}'.format(' '.join(cmd), e.message)
)


if len(sys.argv) != 3:
die("Usage: {0} path_to_training_repo course".format(sys.argv[0]))

course = sys.argv[2]
course_dir = os.path.join("src", course)
manifest = os.path.join(course_dir, "labs.txt")
training_repo = sys.argv[1]

if not os.path.exists(training_repo):
die('Training repo "{0}" does not exist.'.format(training_repo))

if not os.path.exists(course_dir):
die('Course directory "{0}" does not exist.'.format(course_dir))

if not os.path.exists(manifest):
die('Course manifest "{0}" does not exist.'.format(manifest))

master_parse = find_in_path("master_parse")
if master_parse is None:
die("Can't find master_parse in path.")

if os.path.exists(TMP_DIR):
shutil.rmtree(TMP_DIR)


rc = 0
try:
for i in (TMP_DIR, COPY_DIR):
try:
os.mkdir(i)
except OSError as e:
die('Cannot make directory "{0}": {1}'.format(i, e.message))

with open(manifest) as f:
for i, line in enumerate(f.readlines()):
line_number = i + 1
line = line.strip()
if len(line) == 0:
continue
if line.startswith("#"):
continue
tokens = line.split('|')
if len(tokens) != 2:
raise Exception(
'"{0}", line {1}: 2 fields expected, not {2}.'.format(
manifest, line_number, len(tokens)
)
)

source, target = tokens
source = os.path.join(training_repo,
os.path.expanduser(source.strip()))
target = os.path.expanduser(target.strip())

if not os.path.exists(source):
raise Exception(
'"{0}", line {1}: "{2}" does not exist.'.format(
manifest, line_number, source
)
)

if os.path.exists(BUILD_DIR):
shutil.rmtree(BUILD_DIR)

cmd = ["master_parse", "-d", BUILD_DIR, "-ei", "UTF-8", "-eo",
"UTF8", "-py", "-db", "-in", "-st", "-cc", source]
sh(cmd)

dir, file = os.path.split(source)
base, ext = os.path.splitext(file)

student_lab = os.path.join(BUILD_DIR, base, 'python',
'{0}_student.py'.format(base))

target_filename = os.path.basename(target)
tmp_target = os.path.join(COPY_DIR, target_filename)
print "mv {0} {1}".format(student_lab, tmp_target)
shutil.move(student_lab, tmp_target)

target_base, _ = os.path.splitext(target_filename)
cmd = ["gendbc", "--flatten", COPY_DIR,
"{0}.dbc".format(target_base)]
sh(cmd)

shutil.copy(tmp_target, target)


except Exception as e:
sys.stderr.write(e.message + "\n")
rc = 1

finally:
if os.path.exists(TMP_DIR):
shutil.rmtree(TMP_DIR)

sys.exit(rc)

61 changes: 0 additions & 61 deletions build-labs.sh

This file was deleted.

14 changes: 7 additions & 7 deletions cs105_autograder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Databricks notebook source exported at Tue, 21 Jun 2016 17:18:30 UTC

# MAGIC %md
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"/> </a> <br/> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. </a>

# COMMAND ----------

Expand Down Expand Up @@ -116,7 +116,7 @@
# MAGIC
# MAGIC To perform the steps in Part 3, open two browser tabs: one with your lab notebook, and one with this autograder notebook.
# MAGIC
# MAGIC ** Note that you can only submit to the course autograder once every ten minutes. **
# MAGIC ** Note that you can only submit to the course autograder once every one minute. **
# MAGIC
# MAGIC ### Every time you submit to the course autograder, you must perform steps (3a), (3b), (3c), and (3d). ##

Expand Down Expand Up @@ -249,9 +249,9 @@
# Re-run this cell to see the autograder queue status
import json
(result,queue) = client.get_queue_status()
print("Result for get_queue_status(): %s" % result)
print "Result for get_queue_status(): %s" % result
if (queue == []):
print "No submisions for %s found in autograder queue. Proceed to Part 5." % username
print "No submissions for %s found in autograder queue. Proceed to Part 5." % username
else:
# convert result to a Spark DataFrame
df_queue = sqlContext.jsonRDD(sc.parallelize([json.dumps(item) for item in queue]))
Expand All @@ -271,9 +271,9 @@

import json
(result,submission_list) = client.get_submission_list(lab)
print("Result for get_submission_list(): %s" % result)
print "Result for get_submission_list(): %s" % result
if (submission_list == []):
print "No submisions for %s found in autograder queue for lab %s" % (username, lab)
print "All submissions are processed. please go ahead to check your results from autograder."
else:
# convert result to a Spark DataFrame
df_submission_list = sqlContext.jsonRDD(sc.parallelize([json.dumps(item) for item in submission_list]))
Expand Down Expand Up @@ -303,7 +303,7 @@

import json
(result,submission_detail) = client.get_submission_detail(submission_id)
print("Result for get_submission_detail(): %s" % result)
print "Result for get_submission_detail(): %s" % result
print submission_detail['autograder_results']
print submission_detail['grade']

Expand Down
2 changes: 1 addition & 1 deletion cs105_lab0.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Databricks notebook source exported at Sat, 18 Jun 2016 14:10:37 UTC

# MAGIC %md
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"/> </a> <br/> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. </a>

# COMMAND ----------

Expand Down
9 changes: 4 additions & 5 deletions cs105_lab1a_spark_tutorial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Databricks notebook source exported at Fri, 24 Jun 2016 21:33:38 UTC
# Databricks notebook source exported at Fri, 24 Jun 2016 23:04:35 UTC

# MAGIC %md
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"/> </a> <br/> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. </a>

# COMMAND ----------

Expand Down Expand Up @@ -224,10 +224,9 @@
# COMMAND ----------

# MAGIC %md
# MAGIC We're going to use this factory to create a collection of randomly generated people records. In the next section, we'll turn that collection into a DataFrame. We'll use the Spark `Row` class,
# MAGIC because that will help us define the Spark DataFrame schema. There are other ways to define schemas, though; see
# MAGIC We're going to use this factory to create a collection of randomly generated people records. In the next section, we'll turn that collection into a DataFrame. We'll use a Python tuple to help us define the Spark DataFrame schema. There are other ways to define schemas, though; see
# MAGIC the Spark Programming Guide's discussion of [schema inference](http://spark.apache.org/docs/latest/sql-programming-guide.html#inferring-the-schema-using-reflection) for more information. (For instance,
# MAGIC we could also use a Python `namedtuple`.)
# MAGIC we could also use a Python `namedtuple` or a Spark `Row` object.)

# COMMAND ----------

Expand Down
2 changes: 1 addition & 1 deletion cs105_lab1b_word_count.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Databricks notebook source exported at Tue, 21 Jun 2016 17:08:38 UTC

# MAGIC %md
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"/> </a> <br/> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. </a>

# COMMAND ----------

Expand Down
2 changes: 1 addition & 1 deletion cs105_lab2_apache_log.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Databricks notebook source exported at Sat, 2 Jul 2016 14:23:54 UTC

# MAGIC %md
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"/> </a> <br/> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. </a>

# COMMAND ----------

Expand Down
Binary file modified cs120_autograder_complete.dbc
Binary file not shown.
Binary file modified cs120_autograder_register.dbc
Binary file not shown.
Binary file modified cs120_autograder_simpler.dbc
Binary file not shown.
Binary file modified cs120_lab0.dbc
Binary file not shown.
Binary file modified cs120_lab1a_math_review.dbc
Binary file not shown.
Binary file modified cs120_lab1b_word_count_rdd.dbc
Binary file not shown.
Binary file modified cs120_lab2_linear_regression_df.dbc
Binary file not shown.
Binary file modified cs120_lab3_ctr_df.dbc
Binary file not shown.
Binary file modified cs120_lab4_pca.dbc
Binary file not shown.
Loading

0 comments on commit 6e58f30

Please sign in to comment.