Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
Add a binder-specific dockerfile with no build step
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Apr 24, 2018
1 parent b165ad0 commit 02cf709
Show file tree
Hide file tree
Showing 4 changed files with 482 additions and 69 deletions.
316 changes: 316 additions & 0 deletions Features.ipynb

Large diffs are not rendered by default.

196 changes: 139 additions & 57 deletions LiterateDevOps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,16 @@
"> I believe that the time is ripe for significantly better documentation of programs, and that we can best achieve this by considering programs to be works of literature. \n",
"- Donald Knuth's 1984 book _Literate Programming_\n",
"\n",
"Of course, we gave that the old college try and here we are 34 years later and we're still struggling with poor documentation! In the DevOps world, good documentation of prcoesses is more valuable than ever, so what are we to do?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Of course, we gave that the old college try and here we are 34 years later and we're still struggling with poor documentation! In the DevOps world, good documentation of prcoesses is more valuable than ever, so what are we to do?\n",
"\n",
"## How can I motivate you to document better?\n",
"\n",
"I propose some tools which allow you to not only combine your documentation with your code, but with the logs of the execution, reports, etc. If I can't get your attention one way, maybe another will work. "
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "slide"
Expand All @@ -56,24 +47,24 @@
{
"data": {
"text/plain": [
"Directory: /home/jovyan\n",
"Directory: /home/jovyan/work\n",
"\n",
"\n",
"Mode LastWriteTime Length Name \n",
"---- ------------- ------ ---- \n",
"------ 4/10/18 10:05 PM 34643 LiterateDevOps.ipynb \n",
"------ 4/10/18 9:25 PM 2899 build.ps1 \n",
"------ 4/10/18 9:25 PM 3294 Dockerfile \n",
"------ 4/10/18 9:25 PM 4617 jupyter-powershell.nuspec \n",
"------ 4/10/18 9:25 PM 1121 LICENSE.md \n",
"------ 4/10/18 9:25 PM 4210 LiterateDevOps.md \n",
"------ 4/10/18 9:25 PM 12114 nteract - plotly.ipynb \n",
"------ 4/10/18 9:25 PM 168840 ReadMe.ipynb \n",
"------ 4/10/18 9:25 PM 2270 ReadMe.md \n",
"------ 4/10/18 9:25 PM 8453 Release.ipynb"
"--r--- 4/21/18 10:46 PM 33800 LiterateDevOps.ipynb \n",
"--r--- 4/20/18 6:34 AM 1546 Dockerfile \n",
"--r--- 4/20/18 4:19 AM 2974 build.ps1 \n",
"--r--- 4/6/18 3:20 AM 4354 LiterateDevOps.md \n",
"--r--- 4/6/18 3:20 AM 170560 ReadMe.ipynb \n",
"--r--- 4/6/18 3:09 AM 12423 nteract - plotly.ipynb \n",
"--r--- 3/4/18 2:39 AM 2302 ReadMe.md \n",
"--r--- 2/20/18 6:44 AM 4682 jupyter-powershell.nuspec \n",
"--r--- 8/4/17 3:19 AM 8712 Release.ipynb \n",
"--r--- 6/24/17 7:07 AM 1140 LICENSE.md"
]
},
"execution_count": 6,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -83,28 +74,147 @@
"$Files | Sort-Object LastWriteTime -Descending"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The PowerShell kernel also includes a `Write-Jupyter` command that can directly output HTML, javascript, images, etc.\n",
"\n",
"For example: if you take your files and convert them to an HTML table, you can output that table inline. For that to work, you really want to use `ConvertTo-Html -Fragment` to get just the table as output.\n",
"\n",
"of course, we really want that to happen automatically. I'll have to add some `profile` support at some point to make that happen, but in the meantime, you can put something like this in a cell near the top, and make it work from then on:"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"$PSDefaultParameterValues[\"ConvertTo-Html:Fragment\"] = $true"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Incidentally, there's one other problem that I just noticed. Currently, `Write-Jupyter` outputs each item as it comes in, and wraps them in a tag, so to get a table to output properly, you need one output string. ConvertTo-Html outputs one `<tr>` at a time, so we need to use `Out-String` or `-join` them all together:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table><colgroup><col/><col/><col/><col/></colgroup><tr><th>Mode</th><th>LastWriteTime</th><th>Name</th><th>Length</th></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>build.ps1</td><td>2899</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>Dockerfile</td><td>3294</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>jupyter-powershell.nuspec</td><td>4617</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>LICENSE.md</td><td>1121</td></tr><tr><td>------</td><td>4/10/18 10:05:27 PM</td><td>LiterateDevOps.ipynb</td><td>34643</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>LiterateDevOps.md</td><td>4210</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>nteract - plotly.ipynb</td><td>12114</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>ReadMe.ipynb</td><td>168840</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>ReadMe.md</td><td>2270</td></tr><tr><td>------</td><td>4/10/18 9:25:08 PM</td><td>Release.ipynb</td><td>8453</td></tr></table>"
"<table>\n",
"<colgroup><col/><col/><col/><col/></colgroup>\n",
"<tr><th>Mode</th><th>LastWriteTime</th><th>Name</th><th>Length</th></tr>\n",
"<tr><td>--r---</td><td>4/20/18 4:19:33 AM</td><td>build.ps1</td><td>2974</td></tr>\n",
"<tr><td>--r---</td><td>4/20/18 6:34:12 AM</td><td>Dockerfile</td><td>1546</td></tr>\n",
"<tr><td>--r---</td><td>2/20/18 6:44:41 AM</td><td>jupyter-powershell.nuspec</td><td>4682</td></tr>\n",
"<tr><td>--r---</td><td>6/24/17 7:07:27 AM</td><td>LICENSE.md</td><td>1140</td></tr>\n",
"<tr><td>--r---</td><td>4/21/18 10:46:19 PM</td><td>LiterateDevOps.ipynb</td><td>33800</td></tr>\n",
"<tr><td>--r---</td><td>4/6/18 3:20:07 AM</td><td>LiterateDevOps.md</td><td>4354</td></tr>\n",
"<tr><td>--r---</td><td>4/6/18 3:09:39 AM</td><td>nteract - plotly.ipynb</td><td>12423</td></tr>\n",
"<tr><td>--r---</td><td>4/6/18 3:20:07 AM</td><td>ReadMe.ipynb</td><td>170560</td></tr>\n",
"<tr><td>--r---</td><td>3/4/18 2:39:59 AM</td><td>ReadMe.md</td><td>2302</td></tr>\n",
"<tr><td>--r---</td><td>8/4/17 3:19:47 AM</td><td>Release.ipynb</td><td>8712</td></tr>\n",
"</table>\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"($Files | ConvertTo-Html Mode, LastWriteTime, Name, Length -Fragment) -Join \"\" | Write-Jupyter -MimeType html"
"$Files | ConvertTo-Html Mode, LastWriteTime, Name, Length | Out-String | Write-Jupyter -MimeType html"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now if you want to get clever, you can dump a little javascript in, to make the table sortable. run this line, and then use your mouse on the headers of the table:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<script src=\"https://cdn.rawgit.com/stevesouders/5952488/raw/activetable.js\"></script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"'<script src=\"https://cdn.rawgit.com/stevesouders/5952488/raw/activetable.js\"></script>' | Write-Jupyter -MimeType html"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Of course, a better trick would be to make that happen automatically. \n",
"\n",
"I'll see what I can do about that in the future, because this is starting to feel like a lot of modifications for `ConvertTo-Html` -- I'd love some feedback on this. In the meantime, you can add that script to the defaults for `ConvertTo-Html` like what we did with fragment:"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"$PSDefaultParameterValues[\"ConvertTo-Html:Fragment\"] = $true\n",
"$PSDefaultParameterValues[\"ConvertTo-Html:PostContent\"] = '<script src=\"https://cdn.rawgit.com/stevesouders/5952488/raw/activetable.js\"></script>'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now you can get a sortable table instantly, by just running ConvertTo-Html.\n",
"\n",
"When I tried this as an example, I remembered another reason why we're going to want a better ConvertTo-Html. It doesn't know anything about which columns should be visible, and it doesn't handle properties that are collections:"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<colgroup><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/></colgroup>\n",
"<tr><th>LogPipelineExecutionDetails</th><th>Name</th><th>Path</th><th>ImplementingAssembly</th><th>Definition</th><th>Description</th><th>Guid</th><th>HelpInfoUri</th><th>ModuleBase</th><th>PrivateData</th><th>Tags</th><th>ProjectUri</th><th>IconUri</th><th>LicenseUri</th><th>ReleaseNotes</th><th>RepositorySourceLocation</th><th>Version</th><th>ModuleType</th><th>Author</th><th>AccessMode</th><th>ClrVersion</th><th>CompanyName</th><th>Copyright</th><th>DotNetFrameworkVersion</th><th>ExportedFunctions</th><th>Prefix</th><th>ExportedCmdlets</th><th>ExportedCommands</th><th>FileList</th><th>CompatiblePSEditions</th><th>ModuleList</th><th>NestedModules</th><th>PowerShellHostName</th><th>PowerShellHostVersion</th><th>PowerShellVersion</th><th>ProcessorArchitecture</th><th>Scripts</th><th>RequiredAssemblies</th><th>RequiredModules</th><th>RootModule</th><th>ExportedVariables</th><th>ExportedAliases</th><th>ExportedWorkflows</th><th>ExportedDscResources</th><th>SessionState</th><th>OnRemove</th><th>ExportedFormatFiles</th><th>ExportedTypeFiles</th></tr>\n",
"<tr><td>False</td><td>Microsoft.PowerShell.Management</td><td>/usr/src/jupyter-powershell/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1</td><td></td><td></td><td></td><td>eefcb906-b326-4e99-9f54-8b4bb6ef3c6d</td><td>https://go.microsoft.com/fwlink/?linkid=855958</td><td>/usr/src/jupyter-powershell</td><td></td><td>System.Collections.Generic.List`1[System.String]</td><td></td><td></td><td></td><td></td><td></td><td>3.1.0.0</td><td>Manifest</td><td>PowerShell</td><td>ReadWrite</td><td></td><td>Microsoft Corporation</td><td>Copyright (c) Microsoft Corporation. All rights reserved.</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.FunctionInfo]</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.CmdletInfo]</td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.CommandInfo]</td><td>System.Collections.Generic.List`1[System.String]</td><td>System.Collections.Generic.List`1[System.String]</td><td>System.Collections.ObjectModel.Collection`1[System.Object]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSModuleInfo]</td><td></td><td></td><td>3.0</td><td>None</td><td>System.Collections.Generic.List`1[System.String]</td><td>System.Collections.ObjectModel.Collection`1[System.String]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSModuleInfo]</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.PSVariable]</td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.AliasInfo]</td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.FunctionInfo]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]</td><td>System.Management.Automation.SessionState</td><td></td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]</td></tr>\n",
"<tr><td>False</td><td>Microsoft.PowerShell.Utility</td><td>/usr/src/jupyter-powershell/Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1</td><td></td><td></td><td></td><td>1da87e53-152b-403e-98dc-74d7b4d63d59</td><td>https://go.microsoft.com/fwlink/?linkid=855960</td><td>/usr/src/jupyter-powershell</td><td></td><td>System.Collections.Generic.List`1[System.String]</td><td></td><td></td><td></td><td></td><td></td><td>3.1.0.0</td><td>Manifest</td><td>PowerShell</td><td>ReadWrite</td><td></td><td>Microsoft Corporation</td><td>Copyright (c) Microsoft Corporation. All rights reserved.</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.FunctionInfo]</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.CmdletInfo]</td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.CommandInfo]</td><td>System.Collections.Generic.List`1[System.String]</td><td>System.Collections.Generic.List`1[System.String]</td><td>System.Collections.ObjectModel.Collection`1[System.Object]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSModuleInfo]</td><td></td><td></td><td>3.0</td><td>None</td><td>System.Collections.Generic.List`1[System.String]</td><td>System.Collections.ObjectModel.Collection`1[System.String]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.Management.Automation.PSModuleInfo]</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.PSVariable]</td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.AliasInfo]</td><td>System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.FunctionInfo]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]</td><td>System.Management.Automation.SessionState</td><td></td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]</td><td>System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]</td></tr>\n",
"</table>\n",
"<script src=\"https://cdn.rawgit.com/stevesouders/5952488/raw/activetable.js\"></script>\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"Get-Module | ConvertTo-Html | Out-String | Write-Jupyter -MimeType html"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
Expand All @@ -128,44 +238,16 @@
}
},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"Name Value \n",
"---- ----- \n",
"png {137, 80, 78, 71...}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"$imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/2/2f/PowerShell_5.0_icon.png'\n",
"$ImageData = @{ \"png\" = (Invoke-WebRequest $imageUrl -UseBasicParsing).RawContentStream.GetBuffer() }\n",
"$ImageData\n",
"# $ImageData\n",
"\n",
"Write-Jupyter -InputObject $ImageData -Metadata @{ \"image/png\" = @{ 'width' = 32 } }\n",
"Write-Jupyter -InputObject $ImageData -Metadata @{ \"image/png\" = @{ 'width' = 64 } }"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"gci core.PowerShell-Kern.* | remove-item"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 02cf709

Please sign in to comment.