Skip to content

Commit

Permalink
Merge branch 'master' into pd-hints
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmorris committed Dec 11, 2018
2 parents 47ae0ec + 39190e2 commit 1d62e08
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pipeline {
GIT_COMMIT_SHORT = sh(returnStdout: true, script:"git rev-parse --short=7 HEAD").trim()
GIT_COMMIT_SUBJECT = sh(returnStdout: true, script:"git log --format=%s -n 1 HEAD").trim()
GIT_COMMIT_AUTHOR = sh(returnStdout: true, script:"git log --format='%an' -n 1 HEAD").trim()
GIT_COMMIT_SUMMARY = "`<https://github.com/Kaggle/docker-python/commit/${GIT_COMMIT}|${GIT_COMMIT_SHORT}>` ${GIT_COMMIT_SUBJECT} - ${GIT_COMMIT_AUTHOR}"
GIT_COMMIT_SUMMARY = "`<https://github.com/Kaggle/learntools/commit/${GIT_COMMIT}|${GIT_COMMIT_SHORT}>` ${GIT_COMMIT_SUBJECT} - ${GIT_COMMIT_AUTHOR}"
SLACK_CHANNEL = "#learnops"
KAGGLE_KEY = credentials('KAGGLE_API_KEY')
KAGGLE_USERNAME = 'dansbecker'
Expand Down
7 changes: 7 additions & 0 deletions notebooks/examples/example_track/track_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
track = dict(
author_username='colinmorris',
# Keys below are all optional
course_name='Examples',
course_url='https://www.kaggle.com/learn/example',
enable_gpu=True, # Default false
)

# This track consists of two lessons (1 having a tutorial and an exercise,
Expand All @@ -26,6 +30,9 @@
type='tutorial',
# This tutorial corresponds to our first lesson (on the topic of 'example things')
lesson_idx=0,
# In addition to setting this at the track level, we can override it
# on a per-notebook basis.
enable_gpu=False,
),
dict(
filename='ex1-hello.ipynb',
Expand Down
2 changes: 1 addition & 1 deletion notebooks/track_meta_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See also examples/example_track/example_meta.py for a longer, commented example
# See also examples/example_track/track_meta.py for a longer, commented example
track = dict(
author_username='',
)
Expand Down
7 changes: 5 additions & 2 deletions notebooks/track_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def __init__(self, track, lessons_meta, nbs_meta, cfg):
self.lessons[-1].last = True
self.notebooks = []
author = cfg.get('author', track['author_username'])
enable_gpu = track.get('enable_gpu', False)
for nb_meta in nbs_meta:
nb_meta = nb_meta.copy()
nb_meta.setdefault('author', author)
nb_meta.setdefault('enable_gpu', enable_gpu)
lesson_idx = nb_meta.pop('lesson_idx', None)
if lesson_idx is not None:
lesson = self.lessons[lesson_idx]
Expand Down Expand Up @@ -126,7 +128,7 @@ class Notebook(object):

def __init__(self, cfg, filename, type, author=None, title=None, lesson=None,
slug=None, scriptid=1, kernel_sources=(), dataset_sources=(),
competition_sources=(), keywords=(),
competition_sources=(), keywords=(), enable_gpu=False,
):
self.cfg = cfg
self.filename = filename
Expand Down Expand Up @@ -160,6 +162,7 @@ def __init__(self, cfg, filename, type, author=None, title=None, lesson=None,
self.dataset_sources = list(dataset_sources)
self.competition_sources = list(competition_sources)
self.keywords = list(keywords)
self.enable_gpu = bool(enable_gpu)

@staticmethod
def _topic_to_title(topic):
Expand Down Expand Up @@ -204,7 +207,7 @@ def kernel_metadata(self, cfg):
# Path is relative to where kernel-metadata.json file will be written, which is
# notebooks/<track>/<cfg-tag>/kernels_api_metadata/<notebook-identifier>/kernel-metadata.json
code_file="../../rendered/{}".format(self.filename),
enable_gpu=False,
enable_gpu=self.enable_gpu,
# Enable internet in development mode so we can pip install learntools
# TODO: Actually, probably only needs to be turned on if we're in
# development mode AND this is an exercise kernel.
Expand Down

0 comments on commit 1d62e08

Please sign in to comment.