| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Fluid SDK in Python
This Python package is automatically generated by the OpenAPI Generator project:
pip install git+https://github.com/fluid-cloudnative/fluid-client-python.git(you may need to run pip with root permission: sudo pip install git+https://github.com/fluid-cloudnative/fluid-client-python.git)
Then import the package:
import fluidInstall via Setuptools.
python setup.py install --user(or sudo python setup.py install to install the package for all users)
Then import the package:
import fluidPlease follow the installation procedure and then run the following:
The following is a code sample which creates a dataset and get its status.
import logging
import sys
from kubernetes import client
from fluid import FluidK8sClient
from fluid import constants
from fluid import models
logger = logging.getLogger("fluidsdk")
stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
logger.addHandler(stream_handler)
logger.setLevel(logging.INFO)
# Output detailed debug message for fluidsdk
# logger.setLevel(logging.DEBUG)
def main():
fluid_client = FluidK8sClient()
name = "demo"
namespace = "default"
dataset = models.Dataset(
api_version=constants.API_VERSION,
kind=constants.DATASET_KIND,
metadata=client.V1ObjectMeta(
name=name,
namespace=namespace
),
spec=models.DatasetSpec(
mounts=[
models.Mount(
mount_point="https://mirrors.bit.edu.cn/apache/hbase/stable/",
name="hbase",
path="/",
)
]
)
)
try:
fluid_client.create_dataset(dataset)
except Exception as e:
raise RuntimeError(f"Failed to create dataset: {e}")
logger.info(f"Dataset \"{dataset.metadata.namespace}/{dataset.metadata.name}\" created successfully")
try:
dataset = fluid_client.get_dataset(name, namespace)
except Exception as e:
raise RuntimeError(f"Error when getting dataset \"{namespace}/{name}\": {e}")
assert type(dataset) == models.Dataset
logger.info(f"Dataset \"{namespace}/{name}\"'s phase is: {dataset.status.phase}")
if __name__ == '__main__':
main()All endpoints do not require authorization.
| Back | FazBrowse Home | New Git URL |