parent
cdc2b6f5dc
commit
98346003d6
@ -0,0 +1,247 @@
|
||||
<#
|
||||
.Synopsis
|
||||
Activate a Python virtual environment for the current PowerShell session.
|
||||
|
||||
.Description
|
||||
Pushes the python executable for a virtual environment to the front of the
|
||||
$Env:PATH environment variable and sets the prompt to signify that you are
|
||||
in a Python virtual environment. Makes use of the command line switches as
|
||||
well as the `pyvenv.cfg` file values present in the virtual environment.
|
||||
|
||||
.Parameter VenvDir
|
||||
Path to the directory that contains the virtual environment to activate. The
|
||||
default value for this is the parent of the directory that the Activate.ps1
|
||||
script is located within.
|
||||
|
||||
.Parameter Prompt
|
||||
The prompt prefix to display when this virtual environment is activated. By
|
||||
default, this prompt is the name of the virtual environment folder (VenvDir)
|
||||
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
|
||||
|
||||
.Example
|
||||
Activate.ps1
|
||||
Activates the Python virtual environment that contains the Activate.ps1 script.
|
||||
|
||||
.Example
|
||||
Activate.ps1 -Verbose
|
||||
Activates the Python virtual environment that contains the Activate.ps1 script,
|
||||
and shows extra information about the activation as it executes.
|
||||
|
||||
.Example
|
||||
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
|
||||
Activates the Python virtual environment located in the specified location.
|
||||
|
||||
.Example
|
||||
Activate.ps1 -Prompt "MyPython"
|
||||
Activates the Python virtual environment that contains the Activate.ps1 script,
|
||||
and prefixes the current prompt with the specified string (surrounded in
|
||||
parentheses) while the virtual environment is active.
|
||||
|
||||
.Notes
|
||||
On Windows, it may be required to enable this Activate.ps1 script by setting the
|
||||
execution policy for the user. You can do this by issuing the following PowerShell
|
||||
command:
|
||||
|
||||
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||
|
||||
For more information on Execution Policies:
|
||||
https://go.microsoft.com/fwlink/?LinkID=135170
|
||||
|
||||
#>
|
||||
Param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[String]
|
||||
$VenvDir,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[String]
|
||||
$Prompt
|
||||
)
|
||||
|
||||
<# Function declarations --------------------------------------------------- #>
|
||||
|
||||
<#
|
||||
.Synopsis
|
||||
Remove all shell session elements added by the Activate script, including the
|
||||
addition of the virtual environment's Python executable from the beginning of
|
||||
the PATH variable.
|
||||
|
||||
.Parameter NonDestructive
|
||||
If present, do not remove this function from the global namespace for the
|
||||
session.
|
||||
|
||||
#>
|
||||
function global:deactivate ([switch]$NonDestructive) {
|
||||
# Revert to original values
|
||||
|
||||
# The prior prompt:
|
||||
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
|
||||
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
|
||||
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
|
||||
}
|
||||
|
||||
# The prior PYTHONHOME:
|
||||
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
|
||||
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
|
||||
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
|
||||
}
|
||||
|
||||
# The prior PATH:
|
||||
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
|
||||
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
|
||||
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
|
||||
}
|
||||
|
||||
# Just remove the VIRTUAL_ENV altogether:
|
||||
if (Test-Path -Path Env:VIRTUAL_ENV) {
|
||||
Remove-Item -Path env:VIRTUAL_ENV
|
||||
}
|
||||
|
||||
# Just remove VIRTUAL_ENV_PROMPT altogether.
|
||||
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
|
||||
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
|
||||
}
|
||||
|
||||
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
|
||||
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
|
||||
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
|
||||
}
|
||||
|
||||
# Leave deactivate function in the global namespace if requested:
|
||||
if (-not $NonDestructive) {
|
||||
Remove-Item -Path function:deactivate
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.Description
|
||||
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
|
||||
given folder, and returns them in a map.
|
||||
|
||||
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
|
||||
two strings separated by `=` (with any amount of whitespace surrounding the =)
|
||||
then it is considered a `key = value` line. The left hand string is the key,
|
||||
the right hand is the value.
|
||||
|
||||
If the value starts with a `'` or a `"` then the first and last character is
|
||||
stripped from the value before being captured.
|
||||
|
||||
.Parameter ConfigDir
|
||||
Path to the directory that contains the `pyvenv.cfg` file.
|
||||
#>
|
||||
function Get-PyVenvConfig(
|
||||
[String]
|
||||
$ConfigDir
|
||||
) {
|
||||
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
|
||||
|
||||
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
|
||||
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
|
||||
|
||||
# An empty map will be returned if no config file is found.
|
||||
$pyvenvConfig = @{ }
|
||||
|
||||
if ($pyvenvConfigPath) {
|
||||
|
||||
Write-Verbose "File exists, parse `key = value` lines"
|
||||
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
|
||||
|
||||
$pyvenvConfigContent | ForEach-Object {
|
||||
$keyval = $PSItem -split "\s*=\s*", 2
|
||||
if ($keyval[0] -and $keyval[1]) {
|
||||
$val = $keyval[1]
|
||||
|
||||
# Remove extraneous quotations around a string value.
|
||||
if ("'""".Contains($val.Substring(0, 1))) {
|
||||
$val = $val.Substring(1, $val.Length - 2)
|
||||
}
|
||||
|
||||
$pyvenvConfig[$keyval[0]] = $val
|
||||
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
|
||||
}
|
||||
}
|
||||
}
|
||||
return $pyvenvConfig
|
||||
}
|
||||
|
||||
|
||||
<# Begin Activate script --------------------------------------------------- #>
|
||||
|
||||
# Determine the containing directory of this script
|
||||
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$VenvExecDir = Get-Item -Path $VenvExecPath
|
||||
|
||||
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
|
||||
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
|
||||
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
|
||||
|
||||
# Set values required in priority: CmdLine, ConfigFile, Default
|
||||
# First, get the location of the virtual environment, it might not be
|
||||
# VenvExecDir if specified on the command line.
|
||||
if ($VenvDir) {
|
||||
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
|
||||
}
|
||||
else {
|
||||
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
|
||||
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
|
||||
Write-Verbose "VenvDir=$VenvDir"
|
||||
}
|
||||
|
||||
# Next, read the `pyvenv.cfg` file to determine any required value such
|
||||
# as `prompt`.
|
||||
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
|
||||
|
||||
# Next, set the prompt from the command line, or the config file, or
|
||||
# just use the name of the virtual environment folder.
|
||||
if ($Prompt) {
|
||||
Write-Verbose "Prompt specified as argument, using '$Prompt'"
|
||||
}
|
||||
else {
|
||||
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
|
||||
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
|
||||
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
|
||||
$Prompt = $pyvenvCfg['prompt'];
|
||||
}
|
||||
else {
|
||||
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
|
||||
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
|
||||
$Prompt = Split-Path -Path $venvDir -Leaf
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Prompt = '$Prompt'"
|
||||
Write-Verbose "VenvDir='$VenvDir'"
|
||||
|
||||
# Deactivate any currently active virtual environment, but leave the
|
||||
# deactivate function in place.
|
||||
deactivate -nondestructive
|
||||
|
||||
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
|
||||
# that there is an activated venv.
|
||||
$env:VIRTUAL_ENV = $VenvDir
|
||||
|
||||
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
||||
|
||||
Write-Verbose "Setting prompt to '$Prompt'"
|
||||
|
||||
# Set the prompt to include the env name
|
||||
# Make sure _OLD_VIRTUAL_PROMPT is global
|
||||
function global:_OLD_VIRTUAL_PROMPT { "" }
|
||||
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
|
||||
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
|
||||
|
||||
function global:prompt {
|
||||
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
|
||||
_OLD_VIRTUAL_PROMPT
|
||||
}
|
||||
$env:VIRTUAL_ENV_PROMPT = $Prompt
|
||||
}
|
||||
|
||||
# Clear PYTHONHOME
|
||||
if (Test-Path -Path Env:PYTHONHOME) {
|
||||
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
|
||||
Remove-Item -Path Env:PYTHONHOME
|
||||
}
|
||||
|
||||
# Add the venv to the PATH
|
||||
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
|
||||
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
|
@ -0,0 +1,71 @@
|
||||
# This file must be used with "source bin/activate" *from bash*
|
||||
# You cannot run it directly
|
||||
|
||||
deactivate () {
|
||||
# reset old environment variables
|
||||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
||||
PATH="${_OLD_VIRTUAL_PATH:-}"
|
||||
export PATH
|
||||
unset _OLD_VIRTUAL_PATH
|
||||
fi
|
||||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
||||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
||||
export PYTHONHOME
|
||||
unset _OLD_VIRTUAL_PYTHONHOME
|
||||
fi
|
||||
|
||||
# Call hash to forget past locations. Without forgetting
|
||||
# past locations the $PATH changes we made may not be respected.
|
||||
# See "man bash" for more details. hash is usually a builtin of your shell
|
||||
hash -r 2> /dev/null
|
||||
|
||||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||
export PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset VIRTUAL_ENV
|
||||
unset VIRTUAL_ENV_PROMPT
|
||||
if [ ! "${1:-}" = "nondestructive" ] ; then
|
||||
# Self destruct!
|
||||
unset -f deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
# on Windows, a path can contain colons and backslashes and has to be converted:
|
||||
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
|
||||
# transform D:\path\to\venv to /d/path/to/venv on MSYS
|
||||
# and to /cygdrive/d/path/to/venv on Cygwin
|
||||
export VIRTUAL_ENV=$(cygpath /home/patrickd/swarms/swarmsenv)
|
||||
else
|
||||
# use the path as-is
|
||||
export VIRTUAL_ENV=/home/patrickd/swarms/swarmsenv
|
||||
fi
|
||||
|
||||
_OLD_VIRTUAL_PATH="$PATH"
|
||||
PATH="$VIRTUAL_ENV/"bin":$PATH"
|
||||
export PATH
|
||||
|
||||
# unset PYTHONHOME if set
|
||||
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
||||
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
||||
if [ -n "${PYTHONHOME:-}" ] ; then
|
||||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
||||
unset PYTHONHOME
|
||||
fi
|
||||
|
||||
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
||||
_OLD_VIRTUAL_PS1="${PS1:-}"
|
||||
PS1='(swarmsenv) '"${PS1:-}"
|
||||
export PS1
|
||||
VIRTUAL_ENV_PROMPT='(swarmsenv) '
|
||||
export VIRTUAL_ENV_PROMPT
|
||||
fi
|
||||
|
||||
# Call hash to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
hash -r 2> /dev/null
|
@ -0,0 +1,27 @@
|
||||
# This file must be used with "source bin/activate.csh" *from csh*.
|
||||
# You cannot run it directly.
|
||||
|
||||
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
||||
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
|
||||
|
||||
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
|
||||
|
||||
# Unset irrelevant variables.
|
||||
deactivate nondestructive
|
||||
|
||||
setenv VIRTUAL_ENV /home/patrickd/swarms/swarmsenv
|
||||
|
||||
set _OLD_VIRTUAL_PATH="$PATH"
|
||||
setenv PATH "$VIRTUAL_ENV/"bin":$PATH"
|
||||
|
||||
|
||||
set _OLD_VIRTUAL_PROMPT="$prompt"
|
||||
|
||||
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
||||
set prompt = '(swarmsenv) '"$prompt"
|
||||
setenv VIRTUAL_ENV_PROMPT '(swarmsenv) '
|
||||
endif
|
||||
|
||||
alias pydoc python -m pydoc
|
||||
|
||||
rehash
|
@ -0,0 +1,69 @@
|
||||
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
|
||||
# (https://fishshell.com/). You cannot run it directly.
|
||||
|
||||
function deactivate -d "Exit virtual environment and return to normal shell environment"
|
||||
# reset old environment variables
|
||||
if test -n "$_OLD_VIRTUAL_PATH"
|
||||
set -gx PATH $_OLD_VIRTUAL_PATH
|
||||
set -e _OLD_VIRTUAL_PATH
|
||||
end
|
||||
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
||||
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
||||
set -e _OLD_VIRTUAL_PYTHONHOME
|
||||
end
|
||||
|
||||
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
||||
set -e _OLD_FISH_PROMPT_OVERRIDE
|
||||
# prevents error when using nested fish instances (Issue #93858)
|
||||
if functions -q _old_fish_prompt
|
||||
functions -e fish_prompt
|
||||
functions -c _old_fish_prompt fish_prompt
|
||||
functions -e _old_fish_prompt
|
||||
end
|
||||
end
|
||||
|
||||
set -e VIRTUAL_ENV
|
||||
set -e VIRTUAL_ENV_PROMPT
|
||||
if test "$argv[1]" != "nondestructive"
|
||||
# Self-destruct!
|
||||
functions -e deactivate
|
||||
end
|
||||
end
|
||||
|
||||
# Unset irrelevant variables.
|
||||
deactivate nondestructive
|
||||
|
||||
set -gx VIRTUAL_ENV /home/patrickd/swarms/swarmsenv
|
||||
|
||||
set -gx _OLD_VIRTUAL_PATH $PATH
|
||||
set -gx PATH "$VIRTUAL_ENV/"bin $PATH
|
||||
|
||||
# Unset PYTHONHOME if set.
|
||||
if set -q PYTHONHOME
|
||||
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
||||
set -e PYTHONHOME
|
||||
end
|
||||
|
||||
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
||||
# fish uses a function instead of an env var to generate the prompt.
|
||||
|
||||
# Save the current fish_prompt function as the function _old_fish_prompt.
|
||||
functions -c fish_prompt _old_fish_prompt
|
||||
|
||||
# With the original prompt function renamed, we can override with our own.
|
||||
function fish_prompt
|
||||
# Save the return status of the last command.
|
||||
set -l old_status $status
|
||||
|
||||
# Output the venv prompt; color taken from the blue of the Python logo.
|
||||
printf "%s%s%s" (set_color 4B8BBE) '(swarmsenv) ' (set_color normal)
|
||||
|
||||
# Restore the return status of the previous command.
|
||||
echo "exit $old_status" | .
|
||||
# Output the original/"old" prompt.
|
||||
_old_fish_prompt
|
||||
end
|
||||
|
||||
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
||||
set -gx VIRTUAL_ENV_PROMPT '(swarmsenv) '
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from chardet.cli.chardetect import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from caffe2.python.onnx.bin.conversion import caffe2_to_onnx
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(caffe2_to_onnx())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from caffe2.python.onnx.bin.conversion import onnx_to_caffe2
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(onnx_to_caffe2())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from distro.distro import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from dotenv.__main__ import cli
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(cli())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from numpy.f2py.f2py2e import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,75 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
#
|
||||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
||||
# Copyright (c) 2008-2016 California Institute of Technology.
|
||||
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
||||
# License: 3-clause BSD. The full license text is available at:
|
||||
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
||||
'''
|
||||
build profile graph for the given instance
|
||||
|
||||
running:
|
||||
$ get_gprof <args> <instance>
|
||||
|
||||
executes:
|
||||
gprof2dot -f pstats <args> <type>.prof | dot -Tpng -o <type>.call.png
|
||||
|
||||
where:
|
||||
<args> are arguments for gprof2dot, such as "-n 5 -e 5"
|
||||
<instance> is code to create the instance to profile
|
||||
<type> is the class of the instance (i.e. type(instance))
|
||||
|
||||
For example:
|
||||
$ get_gprof -n 5 -e 1 "import numpy; numpy.array([1,2])"
|
||||
|
||||
will create 'ndarray.call.png' with the profile graph for numpy.array([1,2]),
|
||||
where '-n 5' eliminates nodes below 5% threshold, similarly '-e 1' eliminates
|
||||
edges below 1% threshold
|
||||
'''
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) < 2:
|
||||
print ("Please provide an object instance (e.g. 'import math; math.pi')")
|
||||
sys.exit()
|
||||
# grab args for gprof2dot
|
||||
args = sys.argv[1:-1]
|
||||
args = ' '.join(args)
|
||||
# last arg builds the object
|
||||
obj = sys.argv[-1]
|
||||
obj = obj.split(';')
|
||||
# multi-line prep for generating an instance
|
||||
for line in obj[:-1]:
|
||||
exec(line)
|
||||
# one-line generation of an instance
|
||||
try:
|
||||
obj = eval(obj[-1])
|
||||
except Exception:
|
||||
print ("Error processing object instance")
|
||||
sys.exit()
|
||||
|
||||
# get object 'name'
|
||||
objtype = type(obj)
|
||||
name = getattr(objtype, '__name__', getattr(objtype, '__class__', objtype))
|
||||
|
||||
# profile dumping an object
|
||||
import dill
|
||||
import os
|
||||
import cProfile
|
||||
#name = os.path.splitext(os.path.basename(__file__))[0]
|
||||
cProfile.run("dill.dumps(obj)", filename="%s.prof" % name)
|
||||
msg = "gprof2dot -f pstats %s %s.prof | dot -Tpng -o %s.call.png" % (args, name, name)
|
||||
try:
|
||||
res = os.system(msg)
|
||||
except Exception:
|
||||
print ("Please verify install of 'gprof2dot' to view profile graphs")
|
||||
if res:
|
||||
print ("Please verify install of 'gprof2dot' to view profile graphs")
|
||||
|
||||
# get stats
|
||||
f_prof = "%s.prof" % name
|
||||
import pstats
|
||||
stats = pstats.Stats(f_prof, stream=sys.stdout)
|
||||
stats.strip_dirs().sort_stats('cumtime')
|
||||
stats.print_stats(20) #XXX: save to file instead of print top 20?
|
||||
os.remove(f_prof)
|
@ -0,0 +1,54 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
#
|
||||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
||||
# Copyright (c) 2008-2016 California Institute of Technology.
|
||||
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
||||
# License: 3-clause BSD. The full license text is available at:
|
||||
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
||||
"""
|
||||
display the reference paths for objects in ``dill.types`` or a .pkl file
|
||||
|
||||
Notes:
|
||||
the generated image is useful in showing the pointer references in
|
||||
objects that are or can be pickled. Any object in ``dill.objects``
|
||||
listed in ``dill.load_types(picklable=True, unpicklable=True)`` works.
|
||||
|
||||
Examples::
|
||||
|
||||
$ get_objgraph ArrayType
|
||||
Image generated as ArrayType.png
|
||||
"""
|
||||
|
||||
import dill as pickle
|
||||
#pickle.debug.trace(True)
|
||||
#import pickle
|
||||
|
||||
# get all objects for testing
|
||||
from dill import load_types
|
||||
load_types(pickleable=True,unpickleable=True)
|
||||
from dill import objects
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) != 2:
|
||||
print ("Please provide exactly one file or type name (e.g. 'IntType')")
|
||||
msg = "\n"
|
||||
for objtype in list(objects.keys())[:40]:
|
||||
msg += objtype + ', '
|
||||
print (msg + "...")
|
||||
else:
|
||||
objtype = str(sys.argv[-1])
|
||||
try:
|
||||
obj = objects[objtype]
|
||||
except KeyError:
|
||||
obj = pickle.load(open(objtype,'rb'))
|
||||
import os
|
||||
objtype = os.path.splitext(objtype)[0]
|
||||
try:
|
||||
import objgraph
|
||||
objgraph.show_refs(obj, filename=objtype+'.png')
|
||||
except ImportError:
|
||||
print ("Please install 'objgraph' to view object graphs")
|
||||
|
||||
|
||||
# EOF
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from httpx import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from huggingface_hub.commands.huggingface_cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from isympy import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,41 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import json
|
||||
import jsonpatch
|
||||
import argparse
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Diff two JSON files')
|
||||
parser.add_argument('FILE1', type=argparse.FileType('r'))
|
||||
parser.add_argument('FILE2', type=argparse.FileType('r'))
|
||||
parser.add_argument('--indent', type=int, default=None,
|
||||
help='Indent output by n spaces')
|
||||
parser.add_argument('-u', '--preserve-unicode', action='store_true',
|
||||
help='Output Unicode character as-is without using Code Point')
|
||||
parser.add_argument('-v', '--version', action='version',
|
||||
version='%(prog)s ' + jsonpatch.__version__)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
diff_files()
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def diff_files():
|
||||
""" Diffs two JSON files and prints a patch """
|
||||
args = parser.parse_args()
|
||||
doc1 = json.load(args.FILE1)
|
||||
doc2 = json.load(args.FILE2)
|
||||
patch = jsonpatch.make_patch(doc1, doc2)
|
||||
if patch.patch:
|
||||
print(json.dumps(patch.patch, indent=args.indent, ensure_ascii=not(args.preserve_unicode)))
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,107 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
import json
|
||||
import jsonpatch
|
||||
import tempfile
|
||||
import argparse
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Apply a JSON patch on a JSON file')
|
||||
parser.add_argument('ORIGINAL', type=argparse.FileType('r'),
|
||||
help='Original file')
|
||||
parser.add_argument('PATCH', type=argparse.FileType('r'),
|
||||
nargs='?', default=sys.stdin,
|
||||
help='Patch file (read from stdin if omitted)')
|
||||
parser.add_argument('--indent', type=int, default=None,
|
||||
help='Indent output by n spaces')
|
||||
parser.add_argument('-b', '--backup', action='store_true',
|
||||
help='Back up ORIGINAL if modifying in-place')
|
||||
parser.add_argument('-i', '--in-place', action='store_true',
|
||||
help='Modify ORIGINAL in-place instead of to stdout')
|
||||
parser.add_argument('-v', '--version', action='version',
|
||||
version='%(prog)s ' + jsonpatch.__version__)
|
||||
parser.add_argument('-u', '--preserve-unicode', action='store_true',
|
||||
help='Output Unicode character as-is without using Code Point')
|
||||
|
||||
def main():
|
||||
try:
|
||||
patch_files()
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def patch_files():
|
||||
""" Diffs two JSON files and prints a patch """
|
||||
args = parser.parse_args()
|
||||
doc = json.load(args.ORIGINAL)
|
||||
patch = json.load(args.PATCH)
|
||||
result = jsonpatch.apply_patch(doc, patch)
|
||||
|
||||
if args.in_place:
|
||||
dirname = os.path.abspath(os.path.dirname(args.ORIGINAL.name))
|
||||
|
||||
try:
|
||||
# Attempt to replace the file atomically. We do this by
|
||||
# creating a temporary file in the same directory as the
|
||||
# original file so we can atomically move the new file over
|
||||
# the original later. (This is done in the same directory
|
||||
# because atomic renames do not work across mount points.)
|
||||
|
||||
fd, pathname = tempfile.mkstemp(dir=dirname)
|
||||
fp = os.fdopen(fd, 'w')
|
||||
atomic = True
|
||||
|
||||
except OSError:
|
||||
# We failed to create the temporary file for an atomic
|
||||
# replace, so fall back to non-atomic mode by backing up
|
||||
# the original (if desired) and writing a new file.
|
||||
|
||||
if args.backup:
|
||||
os.rename(args.ORIGINAL.name, args.ORIGINAL.name + '.orig')
|
||||
fp = open(args.ORIGINAL.name, 'w')
|
||||
atomic = False
|
||||
|
||||
else:
|
||||
# Since we're not replacing the original file in-place, write
|
||||
# the modified JSON to stdout instead.
|
||||
|
||||
fp = sys.stdout
|
||||
|
||||
# By this point we have some sort of file object we can write the
|
||||
# modified JSON to.
|
||||
|
||||
json.dump(result, fp, indent=args.indent, ensure_ascii=not(args.preserve_unicode))
|
||||
fp.write('\n')
|
||||
|
||||
if args.in_place:
|
||||
# Close the new file. If we aren't replacing atomically, this
|
||||
# is our last step, since everything else is already in place.
|
||||
|
||||
fp.close()
|
||||
|
||||
if atomic:
|
||||
try:
|
||||
# Complete the atomic replace by linking the original
|
||||
# to a backup (if desired), fixing up the permissions
|
||||
# on the temporary file, and moving it into place.
|
||||
|
||||
if args.backup:
|
||||
os.link(args.ORIGINAL.name, args.ORIGINAL.name + '.orig')
|
||||
os.chmod(pathname, os.stat(args.ORIGINAL.name).st_mode)
|
||||
os.rename(pathname, args.ORIGINAL.name)
|
||||
|
||||
except OSError:
|
||||
# In the event we could not actually do the atomic
|
||||
# replace, unlink the original to move it out of the
|
||||
# way and finally move the temporary file into place.
|
||||
|
||||
os.unlink(args.ORIGINAL.name)
|
||||
os.rename(pathname, args.ORIGINAL.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,67 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
|
||||
import jsonpointer
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Resolve a JSON pointer on JSON files')
|
||||
|
||||
# Accept pointer as argument or as file
|
||||
ptr_group = parser.add_mutually_exclusive_group(required=True)
|
||||
|
||||
ptr_group.add_argument('-f', '--pointer-file', type=argparse.FileType('r'),
|
||||
nargs='?',
|
||||
help='File containing a JSON pointer expression')
|
||||
|
||||
ptr_group.add_argument('POINTER', type=str, nargs='?',
|
||||
help='A JSON pointer expression')
|
||||
|
||||
parser.add_argument('FILE', type=argparse.FileType('r'), nargs='+',
|
||||
help='Files for which the pointer should be resolved')
|
||||
parser.add_argument('--indent', type=int, default=None,
|
||||
help='Indent output by n spaces')
|
||||
parser.add_argument('-v', '--version', action='version',
|
||||
version='%(prog)s ' + jsonpointer.__version__)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
resolve_files()
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parse_pointer(args):
|
||||
if args.POINTER:
|
||||
ptr = args.POINTER
|
||||
elif args.pointer_file:
|
||||
ptr = args.pointer_file.read().strip()
|
||||
else:
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
return ptr
|
||||
|
||||
|
||||
def resolve_files():
|
||||
""" Resolve a JSON pointer on JSON files """
|
||||
args = parser.parse_args()
|
||||
|
||||
ptr = parse_pointer(args)
|
||||
|
||||
for f in args.FILE:
|
||||
doc = json.load(f)
|
||||
try:
|
||||
result = jsonpointer.resolve_pointer(doc, ptr)
|
||||
print(json.dumps(result, indent=args.indent))
|
||||
except jsonpointer.JsonPointerException as e:
|
||||
print('Could not resolve pointer: %s' % str(e), file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from jsonschema.cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from langsmith.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from litellm import run_server
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(run_server())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from markdown_it.cli.parse import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from charset_normalizer import cli
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(cli.cli_detect())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from openai.cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,184 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
#
|
||||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
||||
# Copyright (c) 1997-2016 California Institute of Technology.
|
||||
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
||||
# License: 3-clause BSD. The full license text is available at:
|
||||
# - https://github.com/uqfoundation/pathos/blob/master/LICENSE
|
||||
"""
|
||||
connect to the specified machine and start a 'server', 'tunnel', or both
|
||||
|
||||
Notes:
|
||||
Usage: pathos_connect [hostname] [server] [remoteport] [profile]
|
||||
[hostname] - name of the host to connect to
|
||||
[server] - name of RPC server (assumes is installed on host) or 'tunnel'
|
||||
[remoteport] - remote port to use for communication or 'tunnel'
|
||||
[profile] -- name of shell profile to source on remote environment
|
||||
|
||||
Examples::
|
||||
|
||||
$ pathos_connect computer.college.edu ppserver tunnel
|
||||
Usage: pathos_connect [hostname] [server] [remoteport] [profile]
|
||||
[hostname] - name of the host to connect to
|
||||
[server] - name of RPC server (assumes is installed on host) or 'tunnel'
|
||||
[remoteport] - remote port to use for communication or 'tunnel'
|
||||
[profile] -- name of shell profile to source on remote environment
|
||||
defaults are: "localhost" "tunnel" "" ""
|
||||
executing {ssh -N -L 22921:computer.college.edu:15058}'
|
||||
|
||||
Server running at port=15058 with pid=4110
|
||||
Connected to localhost at port=22921
|
||||
Press <Enter> to kill server
|
||||
"""
|
||||
## tunnel: pathos_connect college.edu tunnel
|
||||
## server: pathos_connect college.edu ppserver 12345 .profile
|
||||
## both: pathos_connect college.edu ppserver tunnel .profile
|
||||
|
||||
from pathos.core import *
|
||||
from pathos.hosts import get_profile, register_profiles
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
##### CONFIGURATION & INPUT ########################
|
||||
# set the default remote host
|
||||
rhost = 'localhost'
|
||||
#rhost = 'foobar.internet.org'
|
||||
#rhost = 'computer.college.edu'
|
||||
|
||||
# set any 'special' profiles (those which don't use default_profie)
|
||||
profiles = {}
|
||||
#profiles = {'foobar.internet.org':'.profile',
|
||||
# 'computer.college.edu':'.cshrc'}
|
||||
|
||||
# set the default port
|
||||
rport = ''
|
||||
_rport = '98909'
|
||||
|
||||
# set the default server command
|
||||
server = 'tunnel'
|
||||
#server = 'ppserver' #XXX: "ppserver -p %s" % rport
|
||||
#server = 'classic_server' #XXX: "classic_server -p %s" % rport
|
||||
#server = 'registry_server' #XXX: "registry_server -p %s" % rport
|
||||
|
||||
print("""Usage: pathos_connect [hostname] [remoteport] [server] [profile]
|
||||
Usage: pathos_connect [hostname] [server] [remoteport] [profile]
|
||||
[hostname] - name of the host to connect to
|
||||
[server] - name of RPC server (assumes is installed on host) or 'tunnel'
|
||||
[remoteport] - remote port to use for communication or 'tunnel'
|
||||
[profile] -- name of shell profile to source on remote environment
|
||||
defaults are: "%s" "%s" "%s" "%s".""" % (rhost, server, rport, ''))
|
||||
|
||||
# get remote hostname from user
|
||||
import sys
|
||||
if '--help' in sys.argv:
|
||||
sys.exit(0)
|
||||
try:
|
||||
myinp = sys.argv[1]
|
||||
except: myinp = None
|
||||
if myinp:
|
||||
rhost = myinp #XXX: should test rhost validity here... (how ?)
|
||||
else: pass # use default
|
||||
del myinp
|
||||
|
||||
# get server to run from user
|
||||
try:
|
||||
myinp = sys.argv[2]
|
||||
except: myinp = None
|
||||
if myinp:
|
||||
server = myinp #XXX: should test validity here... (filename)
|
||||
else: pass # use default
|
||||
del myinp
|
||||
|
||||
# set the default 'port'
|
||||
if server == 'tunnel':
|
||||
tunnel = True
|
||||
server = None
|
||||
else:
|
||||
tunnel = False
|
||||
rport = rport if tunnel else _rport
|
||||
|
||||
# get remote port to run server on from user
|
||||
try:
|
||||
myinp = sys.argv[3]
|
||||
except: myinp = None
|
||||
if myinp:
|
||||
if tunnel: # tunnel doesn't take more inputs
|
||||
msg = "port '%s' not valid for 'tunnel'" % myinp
|
||||
raise ValueError(msg)
|
||||
rport = myinp #XXX: should test validity here... (filename)
|
||||
else: pass # use default
|
||||
del myinp
|
||||
|
||||
# is it a tunneled server?
|
||||
tunnel = True if (tunnel or rport == 'tunnel') else False
|
||||
rport = '' if rport == 'tunnel' else rport
|
||||
|
||||
# get remote profile (this should go away soon)
|
||||
try:
|
||||
myinp = sys.argv[4]
|
||||
except: myinp = None
|
||||
if myinp:
|
||||
rprof = myinp #XXX: should test validity here... (filename)
|
||||
profiles = {rhost:rprof}
|
||||
else: pass # use default
|
||||
del myinp
|
||||
|
||||
# my remote environment (should be auto-detected)
|
||||
register_profiles(profiles)
|
||||
profile = get_profile(rhost)
|
||||
|
||||
##### CONFIGURATION & INPUT ########################
|
||||
## tunnel: pathos_connect foo.college.edu tunnel
|
||||
## server: pathos_connect foo.college.edu ppserver 12345 .profile
|
||||
## both: pathos_connect foo.college.edu ppserver tunnel .profile
|
||||
|
||||
if tunnel:
|
||||
# establish ssh tunnel
|
||||
tunnel = connect(rhost)
|
||||
lport = tunnel._lport
|
||||
rport = tunnel._rport
|
||||
print('executing {ssh -N -L %d:%s:%d}' % (lport, rhost, rport))
|
||||
else:
|
||||
lport = ''
|
||||
|
||||
if server:
|
||||
# run server
|
||||
rserver = serve(server, rhost, rport, profile=profile)
|
||||
response = rserver.response()
|
||||
if response:
|
||||
if tunnel: tunnel.disconnect()
|
||||
print(response)
|
||||
raise OSError('Failure to start server')
|
||||
|
||||
# get server pid #FIXME: launcher.pid is not pid(server)
|
||||
target = '[P,p]ython[^#]*'+server # filter w/ regex for python-based server
|
||||
try:
|
||||
pid = getpid(target, rhost)
|
||||
except OSError:
|
||||
print("Cleanup on host may be required...")
|
||||
if tunnel: tunnel.disconnect()
|
||||
raise
|
||||
|
||||
# test server
|
||||
# XXX: add a simple one-liner...
|
||||
print("\nServer running at port=%s with pid=%s" % (rport, pid))
|
||||
if tunnel: print("Connected to localhost at port=%s" % (lport))
|
||||
print('Press <Enter> to kill server')
|
||||
else:
|
||||
print('Press <Enter> to disconnect')
|
||||
sys.stdin.readline()
|
||||
|
||||
if server:
|
||||
# stop server
|
||||
print(kill(pid,rhost))
|
||||
# del rserver #XXX: delete should run self.kill (?)
|
||||
|
||||
if tunnel:
|
||||
# disconnect tunnel
|
||||
tunnel.disconnect()
|
||||
# FIXME: just kills 'ssh', not the tunnel
|
||||
# get local pid: ps u | grep "ssh -N -L%s:%s$s" % (lport,rhost,rport)
|
||||
# kill -15 int(tunnelpid)
|
||||
|
||||
# EOF
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pip._internal.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pip._internal.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pip._internal.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,15 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
#
|
||||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
||||
# Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
|
||||
# License: 3-clause BSD. The full license text is available at:
|
||||
# - https://github.com/uqfoundation/pathos/blob/master/LICENSE
|
||||
|
||||
from pathos.portpicker import portnumber, __doc__
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
pick = portnumber(min=1024,max=65535)
|
||||
print( pick() )
|
||||
|
@ -0,0 +1,27 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
#
|
||||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
||||
# Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
|
||||
# License: 3-clause BSD. The full license text is available at:
|
||||
# - https://github.com/uqfoundation/pox/blob/master/LICENSE
|
||||
|
||||
import pox.__main__
|
||||
from pox.__main__ import *
|
||||
__doc__ = pox.__main__.__doc__
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
import sys
|
||||
try:
|
||||
func = sys.argv[1]
|
||||
except: func = None
|
||||
if func:
|
||||
try:
|
||||
exec('print(%s)' % func)
|
||||
except:
|
||||
print("Error: incorrect syntax '%s'\n" % func)
|
||||
exec('print(%s.__doc__)' % func.split('(')[0])
|
||||
else: help()
|
||||
|
||||
|
||||
# End of file
|
@ -0,0 +1,421 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# Parallel Python Software: http://www.parallelpython.com
|
||||
# Copyright (c) 2005-2012 Vitalii Vanovschi.
|
||||
# Copyright (c) 2015-2016 California Institute of Technology.
|
||||
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
||||
# All rights reserved.
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
# THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
ppft server: the parallel python network server
|
||||
"""
|
||||
import atexit
|
||||
import logging
|
||||
import errno
|
||||
import getopt
|
||||
import sys
|
||||
import socket
|
||||
import threading
|
||||
import random
|
||||
import string
|
||||
import signal
|
||||
import time
|
||||
import os
|
||||
|
||||
import ppft as pp
|
||||
import ppft.auto as ppauto
|
||||
import ppft.common as ppc
|
||||
import ppft.transport as pptransport
|
||||
|
||||
copyright = ppc.copyright
|
||||
__version__ = version = ppc.__version__
|
||||
|
||||
LISTEN_SOCKET_TIMEOUT = 20
|
||||
|
||||
# compatibility with Jython
|
||||
STAT_SIGNAL = 'SIGUSR1' if 'java' not in sys.platform else 'SIGUSR2'
|
||||
|
||||
import hashlib
|
||||
sha_new = hashlib.sha1
|
||||
|
||||
|
||||
class _NetworkServer(pp.Server):
|
||||
"""Network Server Class
|
||||
"""
|
||||
|
||||
def __init__(self, ncpus="autodetect", interface="0.0.0.0",
|
||||
broadcast="255.255.255.255", port=None, secret=None,
|
||||
timeout=None, restart=False, proto=2, socket_timeout=3600, pid_file=None):
|
||||
pp.Server.__init__(self, ncpus, (), secret, restart,
|
||||
proto, socket_timeout)
|
||||
if pid_file:
|
||||
with open(pid_file, 'w') as pfile:
|
||||
print(os.getpid(), file=pfile)
|
||||
atexit.register(os.remove, pid_file)
|
||||
self.host = interface
|
||||
self.bcast = broadcast
|
||||
if port is not None:
|
||||
self.port = port
|
||||
else:
|
||||
self.port = ppc.randomport()
|
||||
self.timeout = timeout
|
||||
self.ncon = 0
|
||||
self.last_con_time = time.time()
|
||||
self.ncon_lock = threading.Lock()
|
||||
|
||||
self.logger.debug("Starting network server interface=%s port=%i"
|
||||
% (self.host, self.port))
|
||||
if self.timeout is not None:
|
||||
self.logger.debug("ppserver will exit in %i seconds if no "\
|
||||
"connections with clients exist" % (self.timeout))
|
||||
ppc.start_thread("timeout_check", self.check_timeout)
|
||||
|
||||
def ncon_add(self, val):
|
||||
"""Keeps track of the number of connections and time of the last one"""
|
||||
self.ncon_lock.acquire()
|
||||
self.ncon += val
|
||||
self.last_con_time = time.time()
|
||||
self.ncon_lock.release()
|
||||
|
||||
def check_timeout(self):
|
||||
"""Checks if timeout happened and shutdowns server if it did"""
|
||||
while True:
|
||||
if self.ncon == 0:
|
||||
idle_time = time.time() - self.last_con_time
|
||||
if idle_time < self.timeout:
|
||||
time.sleep(self.timeout - idle_time)
|
||||
else:
|
||||
self.logger.debug("exiting ppserver due to timeout (no client"\
|
||||
" connections in last %i sec)", self.timeout)
|
||||
os._exit(0)
|
||||
else:
|
||||
time.sleep(self.timeout)
|
||||
|
||||
def listen(self):
|
||||
"""Initiates listenting to incoming connections"""
|
||||
try:
|
||||
self.ssocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
# following allows ppserver to restart faster on the same port
|
||||
self.ssocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.ssocket.settimeout(LISTEN_SOCKET_TIMEOUT)
|
||||
self.ssocket.bind((self.host, self.port))
|
||||
self.ssocket.listen(5)
|
||||
except socket.error:
|
||||
e = sys.exc_info()[1]
|
||||
self.logger.error("Cannot create socket for %s:%s, %s", self.host, self.port, e)
|
||||
|
||||
try:
|
||||
while 1:
|
||||
csocket = None
|
||||
# accept connections from outside
|
||||
try:
|
||||
(csocket, address) = self.ssocket.accept()
|
||||
except socket.timeout:
|
||||
pass
|
||||
# don't exit on an interupt due to a signal
|
||||
except socket.error:
|
||||
e = sys.exc_info()[1]
|
||||
if e.errno == errno.EINTR:
|
||||
pass
|
||||
if self._exiting:
|
||||
return
|
||||
# now do something with the clientsocket
|
||||
# in this case, we'll pretend this is a threaded server
|
||||
if csocket:
|
||||
ppc.start_thread("client_socket", self.crun, (csocket, ))
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except:
|
||||
self.logger.debug("Exception in listen method (possibly expected)", exc_info=True)
|
||||
finally:
|
||||
self.logger.debug("Closing server socket")
|
||||
self.ssocket.close()
|
||||
|
||||
def crun(self, csocket):
|
||||
"""Authenticates client and handles its jobs"""
|
||||
mysocket = pptransport.CSocketTransport(csocket, self.socket_timeout)
|
||||
#send PP version
|
||||
mysocket.send(version)
|
||||
#generate a random string
|
||||
srandom = "".join([random.choice(string.ascii_letters)
|
||||
for i in range(16)])
|
||||
mysocket.send(srandom)
|
||||
answer = sha_new(ppc.b_(srandom+self.secret)).hexdigest()
|
||||
clientanswer = ppc.str_(mysocket.receive())
|
||||
if answer != clientanswer:
|
||||
self.logger.warning("Authentication failed, client host=%s, port=%i"
|
||||
% csocket.getpeername())
|
||||
mysocket.send("FAILED")
|
||||
csocket.close()
|
||||
return
|
||||
else:
|
||||
mysocket.send("OK")
|
||||
|
||||
ctype = ppc.str_(mysocket.receive())
|
||||
self.logger.debug("Control message received: " + ctype)
|
||||
self.ncon_add(1)
|
||||
try:
|
||||
if ctype == "STAT":
|
||||
#reset time at each new connection
|
||||
self.get_stats()["local"].time = 0.0
|
||||
#open('/tmp/pp.debug', 'a+').write('STAT: \n')
|
||||
mysocket.send(str(self.get_ncpus()))
|
||||
#open('/tmp/pp.debug', 'a+').write('STAT: get_ncpus\n')
|
||||
while 1:
|
||||
mysocket.receive()
|
||||
#open('/tmp/pp.debug', 'a+').write('STAT: recvd\n')
|
||||
mysocket.send(str(self.get_stats()["local"].time))
|
||||
#open('/tmp/pp.debug', 'a+').write('STAT: _\n')
|
||||
elif ctype=="EXEC":
|
||||
while 1:
|
||||
#open('/tmp/pp.debug', 'a+').write('EXEC: \n')
|
||||
sfunc = mysocket.creceive()
|
||||
#open('/tmp/pp.debug', 'a+').write('EXEC: '+repr((sfunc,))+'\n')
|
||||
sargs = mysocket.receive()
|
||||
#open('/tmp/pp.debug', 'a+').write('EXEC: '+repr((sargs,))+'\n')
|
||||
fun = self.insert(sfunc, sargs)
|
||||
sresult = fun(True)
|
||||
#open('/tmp/pp.debug', 'a+').write('EXEC: '+repr((sresult,))+'\n')
|
||||
mysocket.send(sresult)
|
||||
#open('/tmp/pp.debug', 'a+').write('EXEC: _\n')
|
||||
except:
|
||||
if self._exiting:
|
||||
return
|
||||
if pp.SHOW_EXPECTED_EXCEPTIONS:
|
||||
self.logger.debug("Exception in crun method (possibly expected)", exc_info=True)
|
||||
self.logger.debug("Closing client socket")
|
||||
csocket.close()
|
||||
self.ncon_add(-1)
|
||||
|
||||
def broadcast(self):
|
||||
"""Initiaates auto-discovery mechanism"""
|
||||
discover = ppauto.Discover(self)
|
||||
ppc.start_thread("server_broadcast", discover.run,
|
||||
((self.host, self.port), (self.bcast, self.port)))
|
||||
|
||||
|
||||
def parse_config(file_loc):
|
||||
"""
|
||||
Parses a config file in a very forgiving way.
|
||||
"""
|
||||
# If we don't have configobj installed then let the user know and exit
|
||||
try:
|
||||
from configobj import ConfigObj
|
||||
except ImportError:
|
||||
ie = sys.exc_info()[1]
|
||||
#sysstderr = getattr(sys.stderr, 'buffer', sys.stderr)
|
||||
print(("ERROR: You must have config obj installed to use"
|
||||
"configuration files. You can still use command line switches."), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if not os.access(file_loc, os.F_OK):
|
||||
print("ERROR: Can not access %s." % arg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
args = {}
|
||||
autodiscovery = False
|
||||
debug = False
|
||||
|
||||
# Load the configuration file
|
||||
config = ConfigObj(file_loc)
|
||||
# try each config item and use the result if it exists. If it doesn't
|
||||
# then simply pass and move along
|
||||
try:
|
||||
args['secret'] = config['general'].get('secret')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
autodiscovery = config['network'].as_bool('autodiscovery')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['interface'] = config['network'].get('interface',
|
||||
default="0.0.0.0")
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['broadcast'] = config['network'].get('broadcast')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['port'] = config['network'].as_int('port')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
debug = config['general'].as_bool('debug')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['ncpus'] = config['general'].as_int('workers')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['proto'] = config['general'].as_int('proto')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['restart'] = config['general'].as_bool('restart')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['timeout'] = config['network'].as_int('timeout')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['socket_timeout'] = config['network'].as_int('socket_timeout')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
args['pid_file'] = config['general'].get('pid_file')
|
||||
except:
|
||||
pass
|
||||
# Return a tuple of the args dict and autodiscovery variable
|
||||
return args, autodiscovery, debug
|
||||
|
||||
|
||||
def print_usage():
|
||||
"""Prints help"""
|
||||
print("Parallel Python Network Server (pp-" + version + ")")
|
||||
print("Usage: ppserver [-hdar] [-f format] [-n proto]"\
|
||||
" [-c config_path] [-i interface] [-b broadcast]"\
|
||||
" [-p port] [-w nworkers] [-s secret] [-t seconds]"\
|
||||
" [-k seconds] [-P pid_file]")
|
||||
print("")
|
||||
print("Options: ")
|
||||
print("-h : this help message")
|
||||
print("-d : set log level to debug")
|
||||
print("-f format : log format")
|
||||
print("-a : enable auto-discovery service")
|
||||
print("-r : restart worker process after each"\
|
||||
" task completion")
|
||||
print("-n proto : protocol number for pickle module")
|
||||
print("-c path : path to config file")
|
||||
print("-i interface : interface to listen")
|
||||
print("-b broadcast : broadcast address for auto-discovery service")
|
||||
print("-p port : port to listen")
|
||||
print("-w nworkers : number of workers to start")
|
||||
print("-s secret : secret for authentication")
|
||||
print("-t seconds : timeout to exit if no connections with "\
|
||||
"clients exist")
|
||||
print("-k seconds : socket timeout in seconds")
|
||||
print("-P pid_file : file to write PID to")
|
||||
print("")
|
||||
print("To print server stats send %s to its main process (unix only). " % STAT_SIGNAL)
|
||||
print("")
|
||||
print("Due to the security concerns always use a non-trivial secret key.")
|
||||
print("Secret key set by -s switch will override secret key assigned by")
|
||||
print("pp_secret variable in .pythonrc.py")
|
||||
print("")
|
||||
print("Please visit http://www.parallelpython.com for extended up-to-date")
|
||||
print("documentation, examples and support forums")
|
||||
|
||||
|
||||
def create_network_server(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, "hdarn:c:b:i:p:w:s:t:f:k:P:", ["help"])
|
||||
except getopt.GetoptError:
|
||||
print_usage()
|
||||
raise
|
||||
|
||||
args = {}
|
||||
autodiscovery = False
|
||||
debug = False
|
||||
|
||||
log_level = logging.WARNING
|
||||
log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
|
||||
for opt, arg in opts:
|
||||
if opt in ("-h", "--help"):
|
||||
print_usage()
|
||||
sys.exit()
|
||||
elif opt == "-c":
|
||||
args, autodiscovery, debug = parse_config(arg)
|
||||
elif opt == "-d":
|
||||
debug = True
|
||||
elif opt == "-f":
|
||||
log_format = arg
|
||||
elif opt == "-i":
|
||||
args["interface"] = arg
|
||||
elif opt == "-s":
|
||||
args["secret"] = arg
|
||||
elif opt == "-p":
|
||||
args["port"] = int(arg)
|
||||
elif opt == "-w":
|
||||
args["ncpus"] = int(arg)
|
||||
elif opt == "-a":
|
||||
autodiscovery = True
|
||||
elif opt == "-r":
|
||||
args["restart"] = True
|
||||
elif opt == "-b":
|
||||
args["broadcast"] = arg
|
||||
elif opt == "-n":
|
||||
args["proto"] = int(arg)
|
||||
elif opt == "-t":
|
||||
args["timeout"] = int(arg)
|
||||
elif opt == "-k":
|
||||
args["socket_timeout"] = int(arg)
|
||||
elif opt == "-P":
|
||||
args["pid_file"] = arg
|
||||
|
||||
if debug:
|
||||
log_level = logging.DEBUG
|
||||
pp.SHOW_EXPECTED_EXCEPTIONS = True
|
||||
|
||||
log_handler = logging.StreamHandler()
|
||||
log_handler.setFormatter(logging.Formatter(log_format))
|
||||
logging.getLogger("pp").setLevel(log_level)
|
||||
logging.getLogger("pp").addHandler(log_handler)
|
||||
|
||||
server = _NetworkServer(**args)
|
||||
if autodiscovery:
|
||||
server.broadcast()
|
||||
return server
|
||||
|
||||
def signal_handler(signum, stack):
|
||||
"""Prints server stats when %s is received (unix only). """ % STAT_SIGNAL
|
||||
server.print_stats()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = create_network_server(sys.argv[1:])
|
||||
statsignal = getattr(signal, STAT_SIGNAL, None)
|
||||
if statsignal:
|
||||
signal.signal(statsignal, signal_handler)
|
||||
server.listen()
|
||||
#have to destroy it here explicitly otherwise an exception
|
||||
#comes out in Python 2.4
|
||||
del server
|
||||
|
||||
|
||||
# Parallel Python Software: http://www.parallelpython.com
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from triton.profiler.proton import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from triton.profiler.viewer import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pygments.cmdline import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pytesseract.pytesseract import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1 @@
|
||||
python3.12
|
@ -0,0 +1 @@
|
||||
python3.12
|
@ -0,0 +1 @@
|
||||
/usr/bin/python3.12
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from ray.scripts.scripts import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from ray.rllib.scripts import cli
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(cli())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from ray.serve.scripts import cli
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(cli())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from swarms.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from tools.flight_recorder.fr_trace import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from torch.distributed.run import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from tqdm.cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from transformers.commands.transformers_cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
@ -0,0 +1,8 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from ray.tune.cli.scripts import cli
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(cli())
|
@ -0,0 +1,22 @@
|
||||
#!/home/patrickd/swarms/swarmsenv/bin/python3.12
|
||||
#
|
||||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
|
||||
# Copyright (c) 2008-2016 California Institute of Technology.
|
||||
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
|
||||
# License: 3-clause BSD. The full license text is available at:
|
||||
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
|
||||
"""
|
||||
unpickle the contents of a pickled object file
|
||||
|
||||
Examples::
|
||||
|
||||
$ undill hello.pkl
|
||||
['hello', 'world']
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
import dill
|
||||
for file in sys.argv[1:]:
|
||||
print (dill.load(open(file,'rb')))
|
||||
|
@ -0,0 +1,164 @@
|
||||
/* -*- indent-tabs-mode: nil; tab-width: 4; -*- */
|
||||
|
||||
/* Greenlet object interface */
|
||||
|
||||
#ifndef Py_GREENLETOBJECT_H
|
||||
#define Py_GREENLETOBJECT_H
|
||||
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is deprecated and undocumented. It does not change. */
|
||||
#define GREENLET_VERSION "1.0.0"
|
||||
|
||||
#ifndef GREENLET_MODULE
|
||||
#define implementation_ptr_t void*
|
||||
#endif
|
||||
|
||||
typedef struct _greenlet {
|
||||
PyObject_HEAD
|
||||
PyObject* weakreflist;
|
||||
PyObject* dict;
|
||||
implementation_ptr_t pimpl;
|
||||
} PyGreenlet;
|
||||
|
||||
#define PyGreenlet_Check(op) (op && PyObject_TypeCheck(op, &PyGreenlet_Type))
|
||||
|
||||
|
||||
/* C API functions */
|
||||
|
||||
/* Total number of symbols that are exported */
|
||||
#define PyGreenlet_API_pointers 12
|
||||
|
||||
#define PyGreenlet_Type_NUM 0
|
||||
#define PyExc_GreenletError_NUM 1
|
||||
#define PyExc_GreenletExit_NUM 2
|
||||
|
||||
#define PyGreenlet_New_NUM 3
|
||||
#define PyGreenlet_GetCurrent_NUM 4
|
||||
#define PyGreenlet_Throw_NUM 5
|
||||
#define PyGreenlet_Switch_NUM 6
|
||||
#define PyGreenlet_SetParent_NUM 7
|
||||
|
||||
#define PyGreenlet_MAIN_NUM 8
|
||||
#define PyGreenlet_STARTED_NUM 9
|
||||
#define PyGreenlet_ACTIVE_NUM 10
|
||||
#define PyGreenlet_GET_PARENT_NUM 11
|
||||
|
||||
#ifndef GREENLET_MODULE
|
||||
/* This section is used by modules that uses the greenlet C API */
|
||||
static void** _PyGreenlet_API = NULL;
|
||||
|
||||
# define PyGreenlet_Type \
|
||||
(*(PyTypeObject*)_PyGreenlet_API[PyGreenlet_Type_NUM])
|
||||
|
||||
# define PyExc_GreenletError \
|
||||
((PyObject*)_PyGreenlet_API[PyExc_GreenletError_NUM])
|
||||
|
||||
# define PyExc_GreenletExit \
|
||||
((PyObject*)_PyGreenlet_API[PyExc_GreenletExit_NUM])
|
||||
|
||||
/*
|
||||
* PyGreenlet_New(PyObject *args)
|
||||
*
|
||||
* greenlet.greenlet(run, parent=None)
|
||||
*/
|
||||
# define PyGreenlet_New \
|
||||
(*(PyGreenlet * (*)(PyObject * run, PyGreenlet * parent)) \
|
||||
_PyGreenlet_API[PyGreenlet_New_NUM])
|
||||
|
||||
/*
|
||||
* PyGreenlet_GetCurrent(void)
|
||||
*
|
||||
* greenlet.getcurrent()
|
||||
*/
|
||||
# define PyGreenlet_GetCurrent \
|
||||
(*(PyGreenlet * (*)(void)) _PyGreenlet_API[PyGreenlet_GetCurrent_NUM])
|
||||
|
||||
/*
|
||||
* PyGreenlet_Throw(
|
||||
* PyGreenlet *greenlet,
|
||||
* PyObject *typ,
|
||||
* PyObject *val,
|
||||
* PyObject *tb)
|
||||
*
|
||||
* g.throw(...)
|
||||
*/
|
||||
# define PyGreenlet_Throw \
|
||||
(*(PyObject * (*)(PyGreenlet * self, \
|
||||
PyObject * typ, \
|
||||
PyObject * val, \
|
||||
PyObject * tb)) \
|
||||
_PyGreenlet_API[PyGreenlet_Throw_NUM])
|
||||
|
||||
/*
|
||||
* PyGreenlet_Switch(PyGreenlet *greenlet, PyObject *args)
|
||||
*
|
||||
* g.switch(*args, **kwargs)
|
||||
*/
|
||||
# define PyGreenlet_Switch \
|
||||
(*(PyObject * \
|
||||
(*)(PyGreenlet * greenlet, PyObject * args, PyObject * kwargs)) \
|
||||
_PyGreenlet_API[PyGreenlet_Switch_NUM])
|
||||
|
||||
/*
|
||||
* PyGreenlet_SetParent(PyObject *greenlet, PyObject *new_parent)
|
||||
*
|
||||
* g.parent = new_parent
|
||||
*/
|
||||
# define PyGreenlet_SetParent \
|
||||
(*(int (*)(PyGreenlet * greenlet, PyGreenlet * nparent)) \
|
||||
_PyGreenlet_API[PyGreenlet_SetParent_NUM])
|
||||
|
||||
/*
|
||||
* PyGreenlet_GetParent(PyObject* greenlet)
|
||||
*
|
||||
* return greenlet.parent;
|
||||
*
|
||||
* This could return NULL even if there is no exception active.
|
||||
* If it does not return NULL, you are responsible for decrementing the
|
||||
* reference count.
|
||||
*/
|
||||
# define PyGreenlet_GetParent \
|
||||
(*(PyGreenlet* (*)(PyGreenlet*)) \
|
||||
_PyGreenlet_API[PyGreenlet_GET_PARENT_NUM])
|
||||
|
||||
/*
|
||||
* deprecated, undocumented alias.
|
||||
*/
|
||||
# define PyGreenlet_GET_PARENT PyGreenlet_GetParent
|
||||
|
||||
# define PyGreenlet_MAIN \
|
||||
(*(int (*)(PyGreenlet*)) \
|
||||
_PyGreenlet_API[PyGreenlet_MAIN_NUM])
|
||||
|
||||
# define PyGreenlet_STARTED \
|
||||
(*(int (*)(PyGreenlet*)) \
|
||||
_PyGreenlet_API[PyGreenlet_STARTED_NUM])
|
||||
|
||||
# define PyGreenlet_ACTIVE \
|
||||
(*(int (*)(PyGreenlet*)) \
|
||||
_PyGreenlet_API[PyGreenlet_ACTIVE_NUM])
|
||||
|
||||
|
||||
|
||||
|
||||
/* Macro that imports greenlet and initializes C API */
|
||||
/* NOTE: This has actually moved to ``greenlet._greenlet._C_API``, but we
|
||||
keep the older definition to be sure older code that might have a copy of
|
||||
the header still works. */
|
||||
# define PyGreenlet_Import() \
|
||||
{ \
|
||||
_PyGreenlet_API = (void**)PyCapsule_Import("greenlet._C_API", 0); \
|
||||
}
|
||||
|
||||
#endif /* GREENLET_MODULE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GREENLETOBJECT_H */
|
@ -0,0 +1 @@
|
||||
lib
|
@ -0,0 +1,5 @@
|
||||
home = /usr/bin
|
||||
include-system-site-packages = false
|
||||
version = 3.12.8
|
||||
executable = /usr/bin/python3.12
|
||||
command = /usr/bin/python3.12 -m venv /home/patrickd/swarms/swarmsenv
|
@ -0,0 +1,188 @@
|
||||
'\" -*- coding: us-ascii -*-
|
||||
.if \n(.g .ds T< \\FC
|
||||
.if \n(.g .ds T> \\F[\n[.fam]]
|
||||
.de URL
|
||||
\\$2 \(la\\$1\(ra\\$3
|
||||
..
|
||||
.if \n(.g .mso www.tmac
|
||||
.TH isympy 1 2007-10-8 "" ""
|
||||
.SH NAME
|
||||
isympy \- interactive shell for SymPy
|
||||
.SH SYNOPSIS
|
||||
'nh
|
||||
.fi
|
||||
.ad l
|
||||
\fBisympy\fR \kx
|
||||
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
||||
'in \n(.iu+\nxu
|
||||
[\fB-c\fR | \fB--console\fR] [\fB-p\fR ENCODING | \fB--pretty\fR ENCODING] [\fB-t\fR TYPE | \fB--types\fR TYPE] [\fB-o\fR ORDER | \fB--order\fR ORDER] [\fB-q\fR | \fB--quiet\fR] [\fB-d\fR | \fB--doctest\fR] [\fB-C\fR | \fB--no-cache\fR] [\fB-a\fR | \fB--auto\fR] [\fB-D\fR | \fB--debug\fR] [
|
||||
-- | PYTHONOPTIONS]
|
||||
'in \n(.iu-\nxu
|
||||
.ad b
|
||||
'hy
|
||||
'nh
|
||||
.fi
|
||||
.ad l
|
||||
\fBisympy\fR \kx
|
||||
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
||||
'in \n(.iu+\nxu
|
||||
[
|
||||
{\fB-h\fR | \fB--help\fR}
|
||||
|
|
||||
{\fB-v\fR | \fB--version\fR}
|
||||
]
|
||||
'in \n(.iu-\nxu
|
||||
.ad b
|
||||
'hy
|
||||
.SH DESCRIPTION
|
||||
isympy is a Python shell for SymPy. It is just a normal python shell
|
||||
(ipython shell if you have the ipython package installed) that executes
|
||||
the following commands so that you don't have to:
|
||||
.PP
|
||||
.nf
|
||||
\*(T<
|
||||
>>> from __future__ import division
|
||||
>>> from sympy import *
|
||||
>>> x, y, z = symbols("x,y,z")
|
||||
>>> k, m, n = symbols("k,m,n", integer=True)
|
||||
\*(T>
|
||||
.fi
|
||||
.PP
|
||||
So starting isympy is equivalent to starting python (or ipython) and
|
||||
executing the above commands by hand. It is intended for easy and quick
|
||||
experimentation with SymPy. For more complicated programs, it is recommended
|
||||
to write a script and import things explicitly (using the "from sympy
|
||||
import sin, log, Symbol, ..." idiom).
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\*(T<\fB\-c \fR\*(T>\fISHELL\fR, \*(T<\fB\-\-console=\fR\*(T>\fISHELL\fR
|
||||
Use the specified shell (python or ipython) as
|
||||
console backend instead of the default one (ipython
|
||||
if present or python otherwise).
|
||||
|
||||
Example: isympy -c python
|
||||
|
||||
\fISHELL\fR could be either
|
||||
\&'ipython' or 'python'
|
||||
.TP
|
||||
\*(T<\fB\-p \fR\*(T>\fIENCODING\fR, \*(T<\fB\-\-pretty=\fR\*(T>\fIENCODING\fR
|
||||
Setup pretty printing in SymPy. By default, the most pretty, unicode
|
||||
printing is enabled (if the terminal supports it). You can use less
|
||||
pretty ASCII printing instead or no pretty printing at all.
|
||||
|
||||
Example: isympy -p no
|
||||
|
||||
\fIENCODING\fR must be one of 'unicode',
|
||||
\&'ascii' or 'no'.
|
||||
.TP
|
||||
\*(T<\fB\-t \fR\*(T>\fITYPE\fR, \*(T<\fB\-\-types=\fR\*(T>\fITYPE\fR
|
||||
Setup the ground types for the polys. By default, gmpy ground types
|
||||
are used if gmpy2 or gmpy is installed, otherwise it falls back to python
|
||||
ground types, which are a little bit slower. You can manually
|
||||
choose python ground types even if gmpy is installed (e.g., for testing purposes).
|
||||
|
||||
Note that sympy ground types are not supported, and should be used
|
||||
only for experimental purposes.
|
||||
|
||||
Note that the gmpy1 ground type is primarily intended for testing; it the
|
||||
use of gmpy even if gmpy2 is available.
|
||||
|
||||
This is the same as setting the environment variable
|
||||
SYMPY_GROUND_TYPES to the given ground type (e.g.,
|
||||
SYMPY_GROUND_TYPES='gmpy')
|
||||
|
||||
The ground types can be determined interactively from the variable
|
||||
sympy.polys.domains.GROUND_TYPES inside the isympy shell itself.
|
||||
|
||||
Example: isympy -t python
|
||||
|
||||
\fITYPE\fR must be one of 'gmpy',
|
||||
\&'gmpy1' or 'python'.
|
||||
.TP
|
||||
\*(T<\fB\-o \fR\*(T>\fIORDER\fR, \*(T<\fB\-\-order=\fR\*(T>\fIORDER\fR
|
||||
Setup the ordering of terms for printing. The default is lex, which
|
||||
orders terms lexicographically (e.g., x**2 + x + 1). You can choose
|
||||
other orderings, such as rev-lex, which will use reverse
|
||||
lexicographic ordering (e.g., 1 + x + x**2).
|
||||
|
||||
Note that for very large expressions, ORDER='none' may speed up
|
||||
printing considerably, with the tradeoff that the order of the terms
|
||||
in the printed expression will have no canonical order
|
||||
|
||||
Example: isympy -o rev-lax
|
||||
|
||||
\fIORDER\fR must be one of 'lex', 'rev-lex', 'grlex',
|
||||
\&'rev-grlex', 'grevlex', 'rev-grevlex', 'old', or 'none'.
|
||||
.TP
|
||||
\*(T<\fB\-q\fR\*(T>, \*(T<\fB\-\-quiet\fR\*(T>
|
||||
Print only Python's and SymPy's versions to stdout at startup, and nothing else.
|
||||
.TP
|
||||
\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-\-doctest\fR\*(T>
|
||||
Use the same format that should be used for doctests. This is
|
||||
equivalent to '\fIisympy -c python -p no\fR'.
|
||||
.TP
|
||||
\*(T<\fB\-C\fR\*(T>, \*(T<\fB\-\-no\-cache\fR\*(T>
|
||||
Disable the caching mechanism. Disabling the cache may slow certain
|
||||
operations down considerably. This is useful for testing the cache,
|
||||
or for benchmarking, as the cache can result in deceptive benchmark timings.
|
||||
|
||||
This is the same as setting the environment variable SYMPY_USE_CACHE
|
||||
to 'no'.
|
||||
.TP
|
||||
\*(T<\fB\-a\fR\*(T>, \*(T<\fB\-\-auto\fR\*(T>
|
||||
Automatically create missing symbols. Normally, typing a name of a
|
||||
Symbol that has not been instantiated first would raise NameError,
|
||||
but with this option enabled, any undefined name will be
|
||||
automatically created as a Symbol. This only works in IPython 0.11.
|
||||
|
||||
Note that this is intended only for interactive, calculator style
|
||||
usage. In a script that uses SymPy, Symbols should be instantiated
|
||||
at the top, so that it's clear what they are.
|
||||
|
||||
This will not override any names that are already defined, which
|
||||
includes the single character letters represented by the mnemonic
|
||||
QCOSINE (see the "Gotchas and Pitfalls" document in the
|
||||
documentation). You can delete existing names by executing "del
|
||||
name" in the shell itself. You can see if a name is defined by typing
|
||||
"'name' in globals()".
|
||||
|
||||
The Symbols that are created using this have default assumptions.
|
||||
If you want to place assumptions on symbols, you should create them
|
||||
using symbols() or var().
|
||||
|
||||
Finally, this only works in the top level namespace. So, for
|
||||
example, if you define a function in isympy with an undefined
|
||||
Symbol, it will not work.
|
||||
.TP
|
||||
\*(T<\fB\-D\fR\*(T>, \*(T<\fB\-\-debug\fR\*(T>
|
||||
Enable debugging output. This is the same as setting the
|
||||
environment variable SYMPY_DEBUG to 'True'. The debug status is set
|
||||
in the variable SYMPY_DEBUG within isympy.
|
||||
.TP
|
||||
-- \fIPYTHONOPTIONS\fR
|
||||
These options will be passed on to \fIipython (1)\fR shell.
|
||||
Only supported when ipython is being used (standard python shell not supported).
|
||||
|
||||
Two dashes (--) are required to separate \fIPYTHONOPTIONS\fR
|
||||
from the other isympy options.
|
||||
|
||||
For example, to run iSymPy without startup banner and colors:
|
||||
|
||||
isympy -q -c ipython -- --colors=NoColor
|
||||
.TP
|
||||
\*(T<\fB\-h\fR\*(T>, \*(T<\fB\-\-help\fR\*(T>
|
||||
Print help output and exit.
|
||||
.TP
|
||||
\*(T<\fB\-v\fR\*(T>, \*(T<\fB\-\-version\fR\*(T>
|
||||
Print isympy version information and exit.
|
||||
.SH FILES
|
||||
.TP
|
||||
\*(T<\fI${HOME}/.sympy\-history\fR\*(T>
|
||||
Saves the history of commands when using the python
|
||||
shell as backend.
|
||||
.SH BUGS
|
||||
The upstreams BTS can be found at \(lahttps://github.com/sympy/sympy/issues\(ra
|
||||
Please report all bugs that you find in there, this will help improve
|
||||
the overall quality of SymPy.
|
||||
.SH "SEE ALSO"
|
||||
\fBipython\fR(1), \fBpython\fR(1)
|
Loading…
Reference in new issue