Skip to content

Commit e6c782a

Browse files
committed
Simplify micrograd PowerShell module setup
1 parent f3e37db commit e6c782a

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

samples/Notebooks/powershell/micrograd/graphHelper.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Requires -Modules @{ ModuleName = 'PSQuickGraph'; ModuleVersion = '2.5.0' }
2+
#Requires -Modules @{ ModuleName = 'PSGraphView'; ModuleVersion = '0.1.0' }
3+
14
function New-ValueNode([Value]$value) {
25
[pscustomobject]@{
36
kind = 'value'
@@ -157,4 +160,4 @@ function Show-ExpressionGraph {
157160
end {
158161

159162
}
160-
}
163+
}

samples/Notebooks/powershell/micrograd/micrograd-ps.verso

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,14 @@
1818
{
1919
"id": "10897b83-f777-43a3-a85c-d5719da8dd1d",
2020
"type": "markdown",
21-
"source": "## Module Setup\n\nUse the local setup cell for repository testing; it imports module manifests from this workspace's `PSGraph/artifacts/local-modules` folder. Use the installed setup cell in a fresh kernel when `PSQuickGraph` and `PSGraphView` are already installed in the normal PowerShell module path.\n\nPowerShell binary modules load .NET assemblies into the runspace process. If one copy of `PSGraph.dll` is already loaded, restart the kernel before switching between local and installed module sources.",
22-
"outputs": []
23-
},
24-
{
25-
"id": "ff7f6f07-7f73-4baa-947c-bb0b3712a056",
26-
"type": "code",
27-
"language": "powershell",
28-
"source": "$ErrorActionPreference = 'Stop'\n\n$loadedPSGraphAssembly = [AppDomain]::CurrentDomain.GetAssemblies() |\n Where-Object { $_.GetName().Name -eq 'PSGraph' } |\n Select-Object -First 1\n\nif ($loadedPSGraphAssembly) {\n Write-Warning 'PSGraph.dll is already loaded. Restart the kernel before switching module sources.'\n Get-Module PSQuickGraph, PSGraphView | Select-Object Name, Version, ModuleBase\n}\nelse {\n $workspaceRoot = Resolve-Path (Join-Path (Get-Location) '../../../../..')\n $repoRoot = Join-Path $workspaceRoot 'PSGraph'\n\n $psQuickGraphManifest = Join-Path $repoRoot 'artifacts/local-modules/PSQuickGraph/PSQuickGraph.psd1'\n $psGraphViewManifest = Join-Path $repoRoot 'artifacts/local-modules/PSGraphView/PSGraphView.psd1'\n\n if (-not (Test-Path -LiteralPath $psQuickGraphManifest)) {\n throw \"PSQuickGraph local manifest not found: $psQuickGraphManifest\"\n }\n\n if (-not (Test-Path -LiteralPath $psGraphViewManifest)) {\n throw \"PSGraphView local manifest not found: $psGraphViewManifest\"\n }\n\n Remove-Module PSQuickGraph, PSGraphView -ErrorAction SilentlyContinue\n Import-Module $psQuickGraphManifest -Force\n Import-Module $psGraphViewManifest -Force\n\n Get-Module PSQuickGraph, PSGraphView |\n Select-Object Name, Version, ModuleBase\n}",
29-
"metadata": {
30-
"verso:ui.inputCollapsed": true
31-
},
21+
"source": "## Module Setup\n\nLoad `PSQuickGraph` and `PSGraphView` from the normal PowerShell module path.",
3222
"outputs": []
3323
},
3424
{
3525
"id": "92379945-af96-4131-a373-7f8fc66bcc7e",
3626
"type": "code",
3727
"language": "powershell",
38-
"source": "$ErrorActionPreference = 'Stop'\n\n$loadedPSGraphAssembly = [AppDomain]::CurrentDomain.GetAssemblies() |\n Where-Object { $_.GetName().Name -eq 'PSGraph' } |\n Select-Object -First 1\n\nif ($loadedPSGraphAssembly) {\n Write-Warning 'PSGraph.dll is already loaded. Restart the kernel before switching module sources.'\n Get-Module PSQuickGraph, PSGraphView | Select-Object Name, Version, ModuleBase\n}\nelse {\n Remove-Module PSQuickGraph, PSGraphView -ErrorAction SilentlyContinue\n Import-Module PSQuickGraph -Force\n Import-Module PSGraphView -Force\n\n Get-Module PSQuickGraph, PSGraphView |\n Select-Object Name, Version, ModuleBase\n}",
28+
"source": "Import-Module PSQuickGraph\nImport-Module PSGraphView",
3929
"outputs": []
4030
},
4131
{

0 commit comments

Comments
 (0)