create_file

This API supports only the MindSpore framework.

Function

with is used to call create_file to create a file and return the corresponding _WriteableFileWrapper instance. The instance provides the write(), drop(), and close() methods.

  • write: writes data to a file.
    write(self, data: bytes)

    Parameter

    Mandatory/Optional

    Description

    Value

    data

    Mandatory

    Object to be written

    bytes object

  • drop: deletes a file.
    drop(self)
  • close: closes a file.
    This method is automatically called when with exits the context.
    close(self)

Format

mindio_acp.create_file(path: str, mode: int = 0o600)

Parameters

Parameter

Mandatory/Optional

Description

Value

path

Mandatory

Data storage path

Valid file path

mode

Optional

File creation permission

[0o000, 0o777]

Usage Example

>>> x = b'\x00\x01\x02\x03\x04'
>>> with mindio_acp.create_file('/mnt/dpc01/checkpoint/rank-0.pt') as f:
...     write_result = f.write(x)

Return Value

_WriteableFileWrapper instance.

For details, see MindSpore documentation.