Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate notebook sources #301

Merged
merged 29 commits into from
Nov 2, 2020

Conversation

karenfeng
Copy link
Collaborator

@karenfeng karenfeng commented Oct 23, 2020

What changes are proposed in this pull request?

Adds generated notebook sources for our documentation for easy diff-ability by converting from HTML to source code. Checks via CI that the generated sources are not out-of-date.

How is this patch tested?

  • Unit tests
  • Integration tests
  • Manual tests

To generate a notebook source yourself:

  • Update your conda environment with the new dependencies
  • Configure your Databricks CLI
  • Run gen-nb-src.py with the input HTML

Example of CI catching failures: https://app.circleci.com/pipelines/github/projectglow/glow/1646/workflows/58e2deeb-7036-468e-8975-bcc3115a04a0/jobs/3878

Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
@codecov
Copy link

codecov bot commented Oct 24, 2020

Codecov Report

Merging #301 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #301   +/-   ##
=======================================
  Coverage   93.53%   93.53%           
=======================================
  Files          95       95           
  Lines        4780     4780           
  Branches      456      456           
=======================================
  Hits         4471     4471           
  Misses        309      309           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 796c98e...b191171. Read the comment docs.

Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Signed-off-by: Karen Feng <[email protected]>
Copy link
Contributor

@henrydavidge henrydavidge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a few comments on the script. This is cool!


print("Generating source file for {} under {} ...".format(html, SOURCE_DIR))

def run_cli_workspace_cmd(args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a nested definition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just so we can leverage cli_profile from the main args, but I can split this out if it's clearer that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be a bit cleaner.

docs/dev/gen-nb-src.py Outdated Show resolved Hide resolved
source_path = os.path.join(SOURCE_DIR, rel_path + "." + ext)
if os.path.exists(source_path):
os.remove(source_path)
print("\tDeleted {}.".format(source_path))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the tab?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We printed a line about the HTML file before this; here, we add a line for all associated generated source files (although reasonably, there should only be 1).


@click.command()
@click.option('--html', required=True, help='Path of the HTML notebook.')
@click.option('--cli-profile', default='docs-ci', help='Databricks CLI profile name.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it make more sense to rely on the databricks CLI's default profile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this useful during manual testing, as I already have a default Databricks CLI profile and wanted to test this on the same shard as the CI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that it makes sense to have this argument, but the default value should be the default profile. If you're running locally, I don't think there's any reason to expect a profile called docs-ci to exist. We can pass the docs-ci argument from our CI script.

@click.command()
@click.option('--html', required=True, help='Path of the HTML notebook.')
@click.option('--cli-profile', default='docs-ci', help='Databricks CLI profile name.')
@click.option('--workspace-tmp-dir', default='/tmp/glow-docs-ci', help='Temp workspace dir for import/export.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably generate a temporary directory if one is not provided. In fact, maybe we should always just make a new one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we do generate a temporary work directory under this; this serves as the root directory. I'll clarify in the description.

Copy link
Contributor

@henrydavidge henrydavidge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small comments


@click.command()
@click.option('--html', required=True, help='Path of the HTML notebook.')
@click.option('--cli-profile', default='docs-ci', help='Databricks CLI profile name.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that it makes sense to have this argument, but the default value should be the default profile. If you're running locally, I don't think there's any reason to expect a profile called docs-ci to exist. We can pass the docs-ci argument from our CI script.


print("Generating source file for {} under {} ...".format(html, SOURCE_DIR))

def run_cli_workspace_cmd(args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be a bit cleaner.

python/environment.yml Outdated Show resolved Hide resolved
Signed-off-by: Karen Feng <[email protected]>
Copy link
Contributor

@henrydavidge henrydavidge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

- pandas=0.25.3
- pip
- pyarrow=0.15.1
- pyspark=3.0.0
- python=3.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's actually standard to list python first since it is pretty important :).

@karenfeng karenfeng merged commit 17e4346 into projectglow:master Nov 2, 2020
@karenfeng karenfeng deleted the generate-notebook-sources branch November 2, 2020 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants