Documentation
¶
Overview ¶
Package utils provides shared utilities for GPU Go.
Index ¶
- Constants
- func AtomicWriteFile(path string, data []byte, perm os.FileMode) error
- func CheckPortAvailability(port int) (int, error)
- func FromTFIsolationMode(mode tfv1.IsolationModeType) string
- func GetRandomAvailablePort() (int, error)
- func LoadJSON[T any](path string) (*T, error)
- func LoadJSONSlice[T any](path string) ([]T, error)
- func SaveJSON[T any](path string, data T, perm os.FileMode) error
- func SaveJSONSlice[T any](path string, data []T, perm os.FileMode) error
- func ToTFIsolationMode(s string) tfv1.IsolationModeType
Constants ¶
const ( IsolationModeSoft = "soft" IsolationModePartitioned = "partitioned" )
IsolationMode constants matching tensor-fusion types
Variables ¶
This section is empty.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile writes data to a file atomically by writing to a temp file first and then renaming. This prevents partial writes on failure.
func CheckPortAvailability ¶
CheckPortAvailability checks if a port is available. If occupied, returns the PID using it (if resolvable) and an error indicating it's in use. If available, returns 0 and nil.
func FromTFIsolationMode ¶
func FromTFIsolationMode(mode tfv1.IsolationModeType) string
FromTFIsolationMode converts tensor-fusion IsolationModeType to string
func GetRandomAvailablePort ¶ added in v1.1.12
GetRandomAvailablePort returns a random available port in the range 9000-9999 Tries up to 100 times to find an available port
func LoadJSON ¶
LoadJSON loads JSON from a file into the provided pointer. Returns nil, nil if file doesn't exist (not an error).
func LoadJSONSlice ¶
LoadJSONSlice loads a JSON array from a file into a slice. Returns nil, nil if file doesn't exist (not an error).
func SaveJSONSlice ¶
SaveJSONSlice saves a slice as JSON to the specified path atomically.
func ToTFIsolationMode ¶
func ToTFIsolationMode(s string) tfv1.IsolationModeType
ToTFIsolationMode converts a string to tensor-fusion IsolationModeType
Types ¶
This section is empty.