Skip to content

Repository files navigation

Mitosis Python SDK

This is the Python client SDK to interact with the Mitosis API. It provides a convenient way to access Mitosis services and manage your resources programmatically.

See the Mitosis documentation and Mitosis repository for more details.

Usage

Install the package with pip

pip install pynetmito

Or if you are using uv, you can add it to your project with:

uv add pynetmito

Now let's see a simple example of how to use the SDK:

frompynetmitoimportMitoHttpClientcoordinator_addr="http://127.0.0.1:5000"# The coordinator address of the mitosis backend servicec=MitoHttpClient(coordinator_addr)
c.connect(user="your-user-name", password="your-password")
# Now you can use the client to submit taskswithopen("orig.txt", "w") asf:
f.write("hello world")
c.upload_attachment(Path("orig.txt"), key="some-remote-text-file/in-object-storage/log.txt")
# Specify the task with attachmentattachment=RemoteResourceDownload(
remote_file=RemoteResource.attachment("some-remote-text-file/in-object-storage/log.txt"), local_path=Path("test.txt")
)
task_spec=TaskSpec(args=["echo", "$MITO_RESOURCE/test.txt"], resources=[attachment], terminal_output=True)
args=SubmitTaskReq(group_name=c.username, task_spec=task_spec)
r=c.user_submit_task(args) # This will return a SubmitTaskResp object (with uuid to identify the task)res=c.get_task_by_uuid(r.uuid) # You can use the uuid to get the task status and resultprint(res)
# To download the terminal output of the taskc.download_artifact(
r.uuid,
content_type=ArtifactContentType.STD_LOG,
local_path=Path("new.txt"),
)

Mitosis API support table

pynetmitoMitosis
0.2.70.6.5 - 0.6.7
0.2.60.6.5 - 0.6.6
0.2.50.6.5 - 0.6.6
0.2.40.6.2 - 0.6.4
0.2.30.6.2
0.2.20.6.1
0.2.10.6.0
0.2.00.6.0
0.1.30.5.3

Releases

Packages

Contributors

Languages