Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit c413fc9

Browse files
authored
Merge branch 'master' into ojarjur/fix-credentials-wrapping
2 parents 69fab54 + 43e04c4 commit c413fc9

20 files changed

+244
-75
lines changed

docs/datalab.bigquery.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
datalab.bigquery package
2-
========================
3-
4-
Module contents
5-
---------------
1+
datalab.bigquery Module
2+
=======================
63

74
.. automodule:: datalab.bigquery
85
:members:

docs/datalab.context.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
datalab.context package
2-
=======================
3-
4-
Module contents
5-
---------------
1+
datalab.context Module
2+
======================
63

74
.. autoclass:: datalab.context.Context
85
:members:

docs/datalab.data.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
datalab.data package
2-
====================
3-
4-
Module contents
5-
---------------
1+
datalab.data Module
2+
===================
63

74
.. automodule:: datalab.data
85
:members:

docs/datalab.stackdriver.monitoring.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
datalab.stackdriver.monitoring package
2-
======================================
3-
4-
Module contents
5-
---------------
1+
datalab.stackdriver.monitoring Module
2+
=====================================
63

74
.. autoclass:: datalab.stackdriver.monitoring.Groups
85
:members:

docs/datalab.storage.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
datalab.storage package
2-
=======================
3-
4-
Module contents
5-
---------------
1+
datalab.storage Module
2+
======================
63

74
.. automodule:: datalab.storage
85
:members:

docs/gen-magic-rst.ipy

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
11
import subprocess, pkgutil, importlib, sys
22
from cStringIO import StringIO
33

4-
5-
IGNORED_MAGICS = []
6-
74
# import submodules
8-
submodules = [s for _,s,_ in pkgutil.iter_modules(['../datalab'])]
9-
10-
for m in submodules:
11-
name = 'datalab.' + m + '.commands'
12-
try:
13-
importlib.import_module(name)
14-
except:
15-
sys.stderr.write('WARNING, could not find module ' + name + '. Ignoring..\n')
16-
17-
magic_regex = "find ../datalab -name '*.py' -exec perl -e '$f=join(\"\",<>); print \"$1\n\" if $f=~/register_line_cell_magic\ndef ([^\(]+)/m' {} \;"
18-
magics = subprocess.check_output(magic_regex, shell=True)
19-
20-
reSTfile = open('datalab.magics.rst', 'w')
21-
indent = '\n '
22-
23-
reSTfile.write('datalab.magics\n')
24-
reSTfile.write('=================\n\n')
25-
26-
for m in magics.split():
27-
if m in IGNORED_MAGICS:
28-
sys.stderr.write('Ignoring magic ' + m + '\n')
29-
else:
30-
reSTfile.write('.. attribute:: ' + m + '\n')
31-
reSTfile.write('.. parsed-literal::\n')
32-
# hijack stdout since the ipython kernel call writes to stdout/err directly
33-
# and does not return its output
34-
tmpStdout, sys.stdout = sys.stdout, StringIO()
35-
get_ipython().magic(m + ' -h')
36-
resultout = sys.stdout.getvalue().splitlines()
37-
sys.stdout = tmpStdout
38-
reSTfile.writelines(indent + indent.join(resultout) + '\n\n')
5+
datalab_submodules = ['datalab.' + s + '.commands' for _,s,_ in pkgutil.iter_modules(['../datalab'])]
6+
google_submodules = ['google.datalab.' + s + '.commands' for _,s,_ in pkgutil.iter_modules(['../google/datalab'])]
7+
8+
def generate_magic_docs(submodules, header, dir, ignored_magics=None):
9+
if not ignored_magics:
10+
ignored_magics = []
11+
for m in submodules:
12+
try:
13+
importlib.import_module(m)
14+
except:
15+
sys.stderr.write('WARNING, could not find module ' + m + '. Ignoring..\n')
16+
17+
magic_regex = "find " + dir + " -name '*.py' -exec perl -e '$f=join(\"\",<>); print \"$1\n\" if $f=~/register_line_cell_magic\ndef ([^\(]+)/m' {} \;"
18+
magics = subprocess.check_output(magic_regex, shell=True)
19+
20+
reSTfile = open(header + '.rst', 'w')
21+
indent = '\n '
22+
23+
reSTfile.write(header + '\n')
24+
reSTfile.write('=======================\n\n')
25+
26+
for m in sorted(magics.split()):
27+
if m in ignored_magics:
28+
sys.stderr.write('Ignoring magic ' + m + '\n')
29+
else:
30+
print('working on magic: '+ m)
31+
reSTfile.write('.. attribute:: %' + m + '\n')
32+
reSTfile.write('.. parsed-literal::\n')
33+
# hijack stdout since the ipython kernel call writes to stdout/err directly
34+
# and does not return its output
35+
tmpStdout, sys.stdout = sys.stdout, StringIO()
36+
get_ipython().magic(m + ' -h')
37+
resultout = sys.stdout.getvalue().splitlines()
38+
sys.stdout = tmpStdout
39+
reSTfile.writelines(indent + indent.join(resultout) + '\n\n')
40+
41+
42+
generate_magic_docs(datalab_submodules, 'datalab Commands', '../datalab', ignored_magics=['chart', 'csv']);
43+
generate_magic_docs(google_submodules, 'google.datalab Commands', '../google');
44+

docs/google.datalab.bigquery.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
google.datalab.bigquery Module
2+
==============================
3+
4+
.. automodule:: google.datalab.bigquery
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
.. autoclass:: google.datalab.bigquery.CSVOptions
10+
:members:
11+
12+
.. autoclass:: google.datalab.bigquery.Dataset
13+
:members:
14+
15+
.. autoclass:: google.datalab.bigquery.DatasetName
16+
:members:
17+
18+
.. autoclass:: google.datalab.bigquery.Datasets
19+
:members:
20+
21+
.. autoclass:: google.datalab.bigquery.ExternalDataSource
22+
:members:
23+
24+
.. autoclass:: google.datalab.bigquery.Query
25+
:members:
26+
27+
.. autoclass:: google.datalab.bigquery.QueryOutput
28+
:members:
29+
30+
.. autoclass:: google.datalab.bigquery.QueryResultsTable
31+
:members:
32+
33+
.. autoclass:: google.datalab.bigquery.QueryStats
34+
:members:
35+
36+
.. autoclass:: google.datalab.bigquery.Sampling
37+
:members:
38+
39+
.. autoclass:: google.datalab.bigquery.Schema
40+
:members:
41+
42+
.. autoclass:: google.datalab.bigquery.SchemaField
43+
:members:
44+
45+
.. autoclass:: google.datalab.bigquery.Table
46+
:members:
47+
48+
.. autoclass:: google.datalab.bigquery.TableMetadata
49+
:members:
50+
51+
.. autoclass:: google.datalab.bigquery.TableName
52+
:members:
53+
54+
.. autoclass:: google.datalab.bigquery.UDF
55+
:members:
56+
57+
.. autoclass:: google.datalab.bigquery.View
58+
:members:

docs/google.datalab.data.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
google.datalab.data Module
2+
==========================
3+
4+
.. automodule:: google.datalab.data
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
.. autoclass:: google.datalab.data.CsvFile
10+
:members:
11+

docs/google.datalab.ml.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
google.datalab.ml Module
2+
========================
3+
4+
.. automodule:: google.datalab.ml
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
.. autoclass:: google.datalab.ml.Job
10+
:members:
11+
12+
.. autoclass:: google.datalab.ml.Jobs
13+
:members:
14+
15+
.. autoclass:: google.datalab.ml.Summary
16+
:members:
17+
18+
.. autoclass:: google.datalab.ml.TensorBoard
19+
:members:
20+
21+
.. autoclass:: google.datalab.ml.CsvDataSet
22+
:members:
23+
24+
.. autoclass:: google.datalab.ml.BigQueryDataSet
25+
:members:
26+
27+
.. autoclass:: google.datalab.ml.Models
28+
:members:
29+
30+
.. autoclass:: google.datalab.ml.ModelVersions
31+
:members:
32+
33+
.. autoclass:: google.datalab.ml.ConfusionMatrix
34+
:members:
35+
36+
.. autoclass:: google.datalab.ml.FeatureSliceView
37+
:members:
38+
39+
.. autoclass:: google.datalab.ml.CloudTrainingConfig
40+
:members:
41+

docs/google.datalab.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
google.datalab Module
2+
=====================
3+
4+
.. automodule:: google.datalab
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
.. autoclass:: google.datalab.Context
10+
:members:
11+
12+
.. autoclass:: google.datalab.Job
13+
:members:
14+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
google.datalab.stackdriver.monitoring Module
2+
============================================
3+
4+
.. autoclass:: google.datalab.stackdriver.monitoring.Groups
5+
:members:
6+
7+
.. autoclass:: google.datalab.stackdriver.monitoring.MetricDescriptors
8+
:members:
9+
10+
.. autoclass:: google.datalab.stackdriver.monitoring.ResourceDescriptors
11+
:members:
12+
13+
.. autoclass:: google.datalab.stackdriver.monitoring.Query
14+
:members:
15+
16+
.. autoclass:: google.datalab.stackdriver.monitoring.QueryMetadata
17+
:members:

docs/google.datalab.storage.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
google.datalab.storage Module
2+
=============================
3+
4+
.. automodule:: google.datalab.storage
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
.. autoclass:: google.datalab.storage.Bucket
10+
:members:
11+
12+
.. autoclass:: google.datalab.storage.Buckets
13+
:members:
14+
15+
.. autoclass:: google.datalab.storage.Object
16+
:members:
17+
18+
.. autoclass:: google.datalab.storage.Objects
19+
:members:
20+

docs/index.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
.. cloud datalab documentation master file, created by
2-
sphinx-quickstart on Tue Nov 3 12:10:12 2015.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
1+
Welcome to Cloud Datalab's documentation
2+
========================================
53

6-
Welcome to Cloud Datalab's documentation!
7-
=========================================
4+
google.datalab namespace
5+
########################
6+
7+
Contents:
8+
9+
.. toctree::
10+
:maxdepth: 4
11+
12+
google.datalab
13+
google.datalab.bigquery
14+
google.datalab.data
15+
google.datalab.ml
16+
google.datalab.stackdriver.monitoring
17+
google.datalab.storage
18+
google.datalab Commands
19+
20+
21+
datalab namespace
22+
#################
23+
24+
Please note, this namespace is planned to be phased out. You are strongly encouraged to move to the new google.datalab namespace above.
825

926
Contents:
1027

@@ -16,7 +33,7 @@ Contents:
1633
datalab.data
1734
datalab.stackdriver.monitoring
1835
datalab.storage
19-
datalab.magics
36+
datalab Commands
2037

2138

2239
Indices and tables

google/datalab/bigquery/commands/_bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def _create_bigquery_parser():
880880
for the handlers that bind the cell contents and thus must recreate this parser for each
881881
cell upon execution.
882882
"""
883-
parser = google.datalab.utils.commands.CommandParser(prog='bq', description="""
883+
parser = google.datalab.utils.commands.CommandParser(prog='%bq', description="""
884884
Execute various BigQuery-related operations. Use "%bq <command> -h"
885885
for help on a specific command.
886886
""")

google/datalab/commands/_datalab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def datalab(line, cell=None):
3636
The results of executing the cell.
3737
"""
3838
parser = google.datalab.utils.commands.CommandParser(
39-
prog='datalab',
39+
prog='%datalab',
4040
description="""
4141
Execute operations that apply to multiple Datalab APIs.
4242

google/datalab/data/_csv_file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ def sample_to(self, count, skip_header_rows, strategy, target):
133133
count: number of rows to sample. If strategy is "BIGQUERY", it is used as approximate number.
134134
skip_header_rows: whether to skip first row when reading from source.
135135
strategy: can be "LOCAL" or "BIGQUERY". If local, the sampling happens in local memory,
136-
and number of resulting rows matches count. If BigQuery, sampling is done
137-
with BigQuery in cloud, and the number of resulting rows will be approximated to
138-
count.
136+
and number of resulting rows matches count. If BigQuery, sampling is done
137+
with BigQuery in cloud, and the number of resulting rows will be approximated to
138+
count.
139139
target: The target file path, can be GCS or local path.
140140
Raises:
141141
Exception if strategy is "BIGQUERY" but source is not a GCS path.

google/datalab/stackdriver/commands/_monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def sd(line, cell=None):
3333
Returns:
3434
The results of executing the cell.
3535
"""
36-
parser = google.datalab.utils.commands.CommandParser(prog='sd', description=(
36+
parser = google.datalab.utils.commands.CommandParser(prog='%sd', description=(
3737
'Execute various Stackdriver related operations. Use "%sd '
3838
'<stackdriver_product> -h" for help on a specific Stackdriver product.'))
3939

google/datalab/storage/commands/_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def gcs(line, cell=None):
6060
Returns:
6161
The results of executing the cell.
6262
"""
63-
parser = google.datalab.utils.commands.CommandParser(prog='gcs', description="""
63+
parser = google.datalab.utils.commands.CommandParser(prog='%gcs', description="""
6464
Execute various Google Cloud Storage related operations. Use "%gcs <command> -h"
6565
for help on a specific command.
6666
""")

0 commit comments

Comments
 (0)