jar.JarManager

jar.JarManager(jar_dir=None, java_path='java')

Manages Josh JAR files.

Handles downloading, caching, and selecting between prod/dev/local jars.

Attributes

Name Type Description
jar_dir Directory where jars are stored.
java_path Path to java executable.

Methods

Name Description
download_jar Download a jar from joshsim.org.
ensure_jars Ensure specified jars are downloaded.
get_info Get information about a jar.
get_jar Get path to a jar, downloading if necessary.
get_jar_path Get the path where a jar would be stored.
jar_exists Check if a jar exists.

download_jar

jar.JarManager.download_jar(mode, force=False, on_progress=None)

Download a jar from joshsim.org.

Parameters

Name Type Description Default
mode JarMode The jar mode (PROD or DEV). LOCAL mode raises ValueError. required
force bool If True, download even if jar already exists. False
on_progress Callable[[int, int], None] | None Optional callback(bytes_downloaded, total_bytes). None

Returns

Name Type Description
DownloadResult DownloadResult with download status.

Raises

Name Type Description
ValueError If mode is LOCAL (can’t download local jars).

ensure_jars

jar.JarManager.ensure_jars(modes=None, force=False)

Ensure specified jars are downloaded.

Parameters

Name Type Description Default
modes list[JarMode] | None List of modes to download. Defaults to [PROD, DEV]. None
force bool If True, re-download even if jars exist. False

Returns

Name Type Description
dict[JarMode, DownloadResult] Dict mapping mode to download result.

get_info

jar.JarManager.get_info(mode)

Get information about a jar.

Parameters

Name Type Description Default
mode JarMode The jar mode. required

Returns

Name Type Description
dict[str, str | None] Dict with ‘path’, ‘exists’, ‘version’, ‘hash’ keys.

get_jar

jar.JarManager.get_jar(mode=JarMode.PROD, local_path=None, auto_download=True)

Get path to a jar, downloading if necessary.

Parameters

Name Type Description Default
mode JarMode The jar mode. JarMode.PROD
local_path Path | None Custom path for LOCAL mode. Ignored for other modes. None
auto_download bool If True, download prod/dev jars if not present. True

Returns

Name Type Description
Path Path to the jar file.

Raises

Name Type Description
FileNotFoundError If jar doesn’t exist and can’t be downloaded.

get_jar_path

jar.JarManager.get_jar_path(mode)

Get the path where a jar would be stored.

Parameters

Name Type Description Default
mode JarMode The jar mode (PROD, DEV, or LOCAL). required

Returns

Name Type Description
Path Path to the jar file.

jar_exists

jar.JarManager.jar_exists(mode)

Check if a jar exists.

Parameters

Name Type Description Default
mode JarMode The jar mode. required

Returns

Name Type Description
bool True if the jar file exists.