Giter VIP home page Giter VIP logo

powershellnotebook's Issues

Handling of Get-NotebookContent conversion failures

It would be great if Get-NotebookContent could be a little more graceful when it runs into an error converting the JSON of a .ipynb file.

For example, this command brings back an error when it tries to process an empty file that just happens to have an .ipynb file extension.

dir -Filter *.ipynb | 
Get-Notebook -Path $_.FullName | 
Group KernelName

Instead of an error, a simple warning message might be better?

Finding all Jupyter Notebooks in subdirectories

When recursively searching through directories, I receive different results when I use foreach{...} around the Get-Notebook function, than when I pipe directly to that same command. If I leave off the -Recurse both versions of the command below return the same results. However, when I include the -Recurse the first version (the one without foreach{...}) only returns results from the top directory level, none of the results from lower directories are included.

dir -Filter *.ipynb -Recurse | 
Get-Notebook -Path $_.FullName | 
Group KernelName
dir -Filter *.ipynb -Recurse | %{
Get-Notebook -Path $_.FullName} | 
Group KernelName

Any support for .NET Interactive notebooks?

I notice that this was made to work with the PowerShell kernel that ships in Azure Data Studio. Do you know how well it works with the .NET Interactive kernel?

I'd love to be able to pull this in and use it there!

Issue with ConvertTo-PowerShell when there is <# and #>

Hello,

I tried converting a couple of PowerShell scripts from tigertoolbox this morning and found a few issues. The Notebook that I used to do the conversion is this: https://gist.githubusercontent.com/MsSQLGirl/b972d381fc85181aeafde5daa15ca171/raw/5d3db3ad14ef06304069bd74b53552b6879f15bf/PowerShellNotebook-ConversionIssue

Exception calling "Substring" with "2" argument(s): "Index and length must refer to a location within the string.
Parameter name: length"
At C:\Users\jukoesma\Documents\WindowsPowerShell\Modules\PowerShellNotebook\2.6.3\ConvertToPowerShellNoteBook.ps1:85 
char:28
+ ...  'Comment' {$TextBlock = $s.Substring($Block.Start, $Block.Length) -r ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentOutOfRangeException
 

I'm exhibiting this error whenever the source powershell file uses <# and #>

Update to advise min powershell version required

Received the following error.

At .....................\WindowsPowerShell\Modules\PowerShellNotebook\2.9.4\InvokeExecuteNotebook.ps1:61 char:100
+ ... rce -DotNetInteractive:$DotNetInteractive | ConvertFrom-Json -Depth 3
+                                                                  ~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [ConvertFrom-Json], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Exception calling "Invoke" with "0" argument(s): "At line:27 char:38
+          throw "(╯°□°)╯︵ ┻�┻"
+                                      ~~~~~~~~
Unexpected token '»â”�â”»"
        exit
    }
}
<#
if ((Get-PackageProvider -Name NuGet).version -lt 2.8.5.201 ) {
    try {
        Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Confirm:$False -Force
    }
    catch [Exception]{
        $_.message                                                                                                                                                                                                                exit                                                                                                                                                                                                                  }                                                                                                                                                                                                                     }                                                                                                                                                                                                                         else {                                                                                                                                                                                                                        Write-Host "Version' in expression or statement.                                                                                                                                                                      At line:59 char:46
+ ... sion of NuGet installed = " (Get-PackageProvider -Name NuGet).version
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
At line:21 char:23
+     catch [Exception] {
+                       ~
Missing closing '}' in statement block or type definition.
At line:7 char:6
+ else {
+      ~
Missing closing '}' in statement block or type definition."
At .....................\Modules\PowerShellNotebook\2.9.4\PowerShellNotebookDSL.ps1:89 char:16
+         return $this.PowerShell.Invoke()
+                ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ParseException

Found that the command ConvertFrom-Json does not use the parameter Depth on versions lower then 6.2, I was running on 5.1.

"Unexpected Token" errors importing PowerShellNotebook (version 2.9.3)

I was installing PowerShellNotebook from PSGallery without MinVersion/MaxVersion and recieved version 2.9.3

Get-Module PowerShellNotebook -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.9.3      PowerShellNotebook                  {Add-NotebookCode, Add-NotebookMarkdown, Convert-MarkdownT...

When I tried to import the module I recieved the following:

> Install-Module PowerShellNotebook -Scope AllUsers -Repository PSGallery

> Import-Module PowerShellNotebook
At C:\Program Files\WindowsPowerShell\Modules\PowerShellNotebook\2.9.3\New-InteractiveNotebook.ps1:14 char:102
+ ... ls.dotnet-interactive-vscode/newNotebook?as={0}" -f ($AsDib ? 'dib':' ...
+                                                                 ~
Unexpected token '?' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellNotebook\2.9.3\New-InteractiveNotebook.ps1:14 char:101
+ ... ools.dotnet-interactive-vscode/newNotebook?as={0}" -f ($AsDib ? 'dib' ...
+                                                                  ~
Missing closing ')' in expression.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellNotebook\2.9.3\New-InteractiveNotebook.ps1:1 char:34
+ function New-InteractiveNotebook {
+                                  ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellNotebook\2.9.3\New-InteractiveNotebook.ps1:14 char:117
+ ... t-interactive-vscode/newNotebook?as={0}" -f ($AsDib ? 'dib':'ipynb'))
+                                                                        ~
Unexpected token ')' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellNotebook\2.9.3\New-InteractiveNotebook.ps1:14 char:118
+ ... t-interactive-vscode/newNotebook?as={0}" -f ($AsDib ? 'dib':'ipynb'))
+                                                                         ~
Unexpected token ')' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellNotebook\2.9.3\New-InteractiveNotebook.ps1:15 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

This was with Windows PowerShell 5.1

I've reverted to version 2.9.1 and was able to import PowerShellNotebook successfully.

Please let me know if I can provide any further information.

TODO - Enhance Invoke-ExecuteNotebook

  • Catch and report errors
  • Change new parameters to injected-parameters for New-CodeCell
  • If there are no cells tagged as parameters insert it at the beginning
  • Inject the new parameters only once, after the first
    - [ ] Handle targets like arrays passed in the hashtable
  • If the cell has not output.text, need to create it
  • Support reading a notebook from a URL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.