polyfoammesh.commercial.cloud_mesh

Collaborative / Cloud meshing — submit mesh jobs to remote clusters.

Provides:
  • REST API client for remote meshing service (Slurm / AWS Batch / generic)

  • Job submission, polling, and result download

  • Session sharing via share-link export/import

  • Local job queuing with remote dispatch

Usage:

client = CloudMesher(api_url="https://mesh.example.com/api")
job = client.submit(case_dir="/path/to/case", n_cores=16)
print(f"Job {job.id} submitted, status: {job.status}")
job.wait()
client.download_result(job, output_dir="./results")

Classes

CloudMesher([api_url, api_key])

Remote/cluster meshing client.

JobStatus(value)

MeshJob([id, status, case_dir, n_cores, ...])

A remote meshing job.

ShareLink([session_id, created_at, ...])

A shareable link to a meshing session.

class polyfoammesh.commercial.cloud_mesh.JobStatus(value)[source]

Bases: Enum

PENDING = 'pending'
RUNNING = 'running'
COMPLETED = 'completed'
FAILED = 'failed'
CANCELLED = 'cancelled'
NOT_SUBMITTED = 'not_submitted'
class polyfoammesh.commercial.cloud_mesh.MeshJob(id='', status=JobStatus.PENDING, case_dir='', n_cores=1, max_cell=0.05, min_cell=0.01, description='', created_at='', completed_at='', cell_count=0, error='', result_url='')[source]

Bases: object

A remote meshing job.

Parameters:
id: str = ''
status: JobStatus = 'pending'
case_dir: str = ''
n_cores: int = 1
max_cell: float = 0.05
min_cell: float = 0.01
description: str = ''
created_at: str = ''
completed_at: str = ''
cell_count: int = 0
error: str = ''
result_url: str = ''
to_dict()[source]
Return type:

dict[str, Any]

Bases: object

A shareable link to a meshing session.

Parameters:
session_id: str = ''
created_at: str = ''
expires_at: str = ''
case_dir: str = ''
params: dict[str, Any]
url: str = ''
class polyfoammesh.commercial.cloud_mesh.CloudMesher(api_url='', api_key='')[source]

Bases: object

Remote/cluster meshing client.

Connects to a REST API endpoint that dispatches mesh jobs to Slurm, PBS, AWS Batch, or a generic worker pool.

Usage:

cm = CloudMesher(api_url="https://mesh.example.com/api")
cm.authenticate("api-key-123")

job = cm.submit(
    case_dir="/data/case1",
    n_cores=8,
    description="Pipe junction mesh",
)
job = cm.poll(job.id)
if job.status == JobStatus.COMPLETED:
    cm.download_result(job, "./results")
Parameters:
authenticate(api_key)[source]

Set the API key for authenticated requests.

Return type:

None

Parameters:

api_key (str)

submit(case_dir='', n_cores=1, max_cell=0.05, min_cell=0.01, description='')[source]

Submit a meshing job to the remote service.

If no API URL is configured, creates a local-only job record (offline mode).

Return type:

MeshJob

Parameters:
poll(job_id)[source]

Poll a remote job for status update.

Falls back to returning a local status when no API is configured.

Return type:

MeshJob

Parameters:

job_id (str)

cancel(job_id)[source]

Cancel a running job.

Return type:

bool

Parameters:

job_id (str)

wait(job, poll_interval=5.0, timeout=3600.0)[source]

Block until the job completes, fails, or is cancelled.

Parameters:
  • job (MeshJob) – The job to wait for.

  • poll_interval (float) – Seconds between status checks.

  • timeout (float) – Maximum seconds to wait.

Return type:

MeshJob

Returns:

Updated MeshJob with final status.

download_result(job, output_dir)[source]

Download the meshing result archive for a completed job.

Parameters:
  • job (MeshJob) – Completed job with a result_url.

  • output_dir (Path | str) – Local directory to write the result.

Return type:

Path

Returns:

Path to the downloaded archive.

Create a shareable link for a meshing session.

Exports the current case configuration as a share link that can be imported by another user.

Return type:

ShareLink

Parameters:
export_share_data(link)[source]

Export a share link as a JSON string (for clipboard/file).

Return type:

str

Parameters:

link (ShareLink)

static import_share_data(json_str)[source]

Import a share link from a JSON string.

Return type:

ShareLink

Parameters:

json_str (str)