or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

artifact-config.mdartifacts.mdclient.mdconfig.mdenums.mdexceptions.mdhooks.mdindex.mdintegrations.mdmaterializers.mdmetadata-tags.mdmodels.mdpipelines-and-steps.mdpydantic-models.mdservices.mdstack-components.mdstacks.mdtypes.mdutilities.md

client.mddocs/

0

# Client

1

2

The Client class is the main programmatic interface for interacting with ZenML. It provides access to all ZenML resources including stacks, pipelines, artifacts, models, secrets, users, projects, and more. The Client follows a singleton pattern and maintains connection to the ZenML server or local store.

3

4

## Capabilities

5

6

### Client Class

7

8

```python { .api }

9

class Client:

10

"""

11

Main interface for interacting with ZenML programmatically.

12

13

The Client provides methods for managing all ZenML resources and

14

follows a singleton pattern for consistent state management.

15

16

Singleton access:

17

```python

18

from zenml.client import Client

19

client = Client()

20

```

21

"""

22

23

@staticmethod

24

def get_instance():

25

"""

26

Get singleton client instance.

27

28

Returns:

29

Client: The singleton client instance

30

"""

31

32

@staticmethod

33

def initialize(root: str = None):

34

"""

35

Initialize ZenML repository.

36

37

Parameters:

38

- root: Root directory for ZenML repository (default: current directory)

39

40

Returns:

41

Client: Initialized client instance

42

"""

43

44

@staticmethod

45

def is_repository_directory(path: str = None) -> bool:

46

"""

47

Check if path is a ZenML repository.

48

49

Parameters:

50

- path: Path to check (default: current directory)

51

52

Returns:

53

bool: True if path is a ZenML repository

54

"""

55

56

@staticmethod

57

def find_repository(path: str = None) -> str:

58

"""

59

Find ZenML repository in path hierarchy.

60

61

Parameters:

62

- path: Starting path (default: current directory)

63

64

Returns:

65

str: Path to repository root

66

67

Raises:

68

RuntimeError: If no repository found

69

"""

70

71

@staticmethod

72

def is_inside_repository(path: str = None) -> bool:

73

"""

74

Check if path is inside a ZenML repository.

75

76

Parameters:

77

- path: Path to check (default: current directory)

78

79

Returns:

80

bool: True if inside a repository

81

"""

82

83

@property

84

def zen_store(self):

85

"""

86

Access to the underlying ZenML store.

87

88

Returns:

89

ZenStore: Store instance for direct store operations

90

"""

91

92

@property

93

def root(self) -> str:

94

"""

95

Root directory of ZenML repository.

96

97

Returns:

98

str: Repository root path

99

"""

100

101

@property

102

def config_directory(self) -> str:

103

"""

104

Configuration directory path.

105

106

Returns:

107

str: Config directory path

108

"""

109

110

def uses_local_configuration(self) -> bool:

111

"""

112

Check if using local configuration.

113

114

Returns:

115

bool: True if using local config

116

"""

117

```

118

119

Import from:

120

121

```python

122

from zenml.client import Client

123

```

124

125

### Active Resource Properties

126

127

```python { .api }

128

class Client:

129

@property

130

def active_stack(self):

131

"""

132

Get the active stack object.

133

134

Returns:

135

Stack: Active stack with all components initialized

136

"""

137

138

@property

139

def active_stack_model(self):

140

"""

141

Get the active stack model.

142

143

Returns:

144

StackResponse: Active stack model with configuration

145

"""

146

147

@property

148

def active_project(self):

149

"""

150

Get the active project.

151

152

Returns:

153

ProjectResponse: Active project information

154

"""

155

156

@property

157

def active_user(self):

158

"""

159

Get the active user.

160

161

Returns:

162

UserResponse: Active user information

163

"""

164

165

def set_active_project(self, project_name_or_id: str):

166

"""

167

Set the active project.

168

169

Parameters:

170

- project_name_or_id: Project name or UUID

171

"""

172

173

def activate_stack(self, stack_name_or_id: str):

174

"""

175

Set the active stack.

176

177

Parameters:

178

- stack_name_or_id: Stack name or UUID

179

"""

180

```

181

182

### User Management

183

184

```python { .api }

185

class Client:

186

def create_user(

187

self,

188

name: str,

189

password: str = None,

190

is_admin: bool = False

191

):

192

"""

193

Create a new user.

194

195

Parameters:

196

- name: Username

197

- password: User password (optional)

198

- is_admin: Whether user has admin privileges

199

200

Returns:

201

UserResponse: Created user

202

"""

203

204

def get_user(

205

self,

206

name_or_id: str = None,

207

allow_name_prefix_match: bool = True

208

):

209

"""

210

Get user by name or ID.

211

212

Parameters:

213

- name_or_id: Username or UUID (current user if None)

214

- allow_name_prefix_match: Allow prefix matching

215

216

Returns:

217

UserResponse: User information

218

"""

219

220

def list_users(

221

self,

222

name: str = None,

223

is_admin: bool = None,

224

**kwargs

225

):

226

"""

227

List all users.

228

229

Parameters:

230

- name: Filter by name

231

- is_admin: Filter by admin status

232

- **kwargs: Additional filter parameters

233

234

Returns:

235

Page[UserResponse]: Paginated list of users

236

"""

237

238

def update_user(

239

self,

240

name_or_id: str,

241

updated_name: str = None,

242

updated_full_name: str = None,

243

updated_email: str = None,

244

updated_email_opted_in: bool = None,

245

is_admin: bool = None

246

):

247

"""

248

Update user information.

249

250

Parameters:

251

- name_or_id: User name or UUID

252

- updated_name: New username

253

- updated_full_name: New full name

254

- updated_email: New email

255

- updated_email_opted_in: Email opt-in status

256

- is_admin: Admin status

257

258

Returns:

259

UserResponse: Updated user

260

"""

261

262

def deactivate_user(self, name_or_id: str):

263

"""

264

Deactivate a user.

265

266

Parameters:

267

- name_or_id: User name or UUID

268

"""

269

270

def delete_user(self, name_or_id: str):

271

"""

272

Delete a user.

273

274

Parameters:

275

- name_or_id: User name or UUID

276

"""

277

```

278

279

### Project Management

280

281

```python { .api }

282

class Client:

283

def create_project(

284

self,

285

name: str,

286

description: str = None

287

):

288

"""

289

Create a new project.

290

291

Parameters:

292

- name: Project name

293

- description: Project description

294

295

Returns:

296

ProjectResponse: Created project

297

"""

298

299

def get_project(self, name_or_id: str = None):

300

"""

301

Get project by name or ID.

302

303

Parameters:

304

- name_or_id: Project name or UUID (active project if None)

305

306

Returns:

307

ProjectResponse: Project information

308

"""

309

310

def list_projects(self, name: str = None, **kwargs):

311

"""

312

List all projects.

313

314

Parameters:

315

- name: Filter by name

316

- **kwargs: Additional filter parameters

317

318

Returns:

319

Page[ProjectResponse]: Paginated list of projects

320

"""

321

322

def update_project(

323

self,

324

name_or_id: str,

325

updated_name: str = None,

326

updated_description: str = None

327

):

328

"""

329

Update project information.

330

331

Parameters:

332

- name_or_id: Project name or UUID

333

- updated_name: New project name

334

- updated_description: New description

335

336

Returns:

337

ProjectResponse: Updated project

338

"""

339

340

def delete_project(self, name_or_id: str):

341

"""

342

Delete a project.

343

344

Parameters:

345

- name_or_id: Project name or UUID

346

"""

347

```

348

349

### Stack Management

350

351

```python { .api }

352

class Client:

353

def create_stack(

354

self,

355

name: str,

356

components: dict,

357

description: str = None

358

):

359

"""

360

Create a new stack.

361

362

Parameters:

363

- name: Stack name

364

- components: Dict mapping component type to component name/ID

365

- description: Stack description

366

367

Returns:

368

StackResponse: Created stack

369

370

Example:

371

```python

372

stack = client.create_stack(

373

name="my_stack",

374

components={

375

"orchestrator": "local_orchestrator",

376

"artifact_store": "local_artifact_store"

377

},

378

description="Local development stack"

379

)

380

```

381

"""

382

383

def get_stack(self, name_or_id: str = None):

384

"""

385

Get stack by name or ID.

386

387

Parameters:

388

- name_or_id: Stack name or UUID (active stack if None)

389

390

Returns:

391

StackResponse: Stack information

392

"""

393

394

def list_stacks(

395

self,

396

name: str = None,

397

component_id: str = None,

398

**kwargs

399

):

400

"""

401

List all stacks.

402

403

Parameters:

404

- name: Filter by name

405

- component_id: Filter by component UUID

406

- **kwargs: Additional filter parameters

407

408

Returns:

409

Page[StackResponse]: Paginated list of stacks

410

"""

411

412

def update_stack(

413

self,

414

name_or_id: str,

415

updated_name: str = None,

416

updated_description: str = None,

417

components: dict = None

418

):

419

"""

420

Update stack configuration.

421

422

Parameters:

423

- name_or_id: Stack name or UUID

424

- updated_name: New stack name

425

- updated_description: New description

426

- components: Updated components dict

427

428

Returns:

429

StackResponse: Updated stack

430

"""

431

432

def delete_stack(self, name_or_id: str):

433

"""

434

Delete a stack.

435

436

Parameters:

437

- name_or_id: Stack name or UUID

438

"""

439

```

440

441

### Stack Component Management

442

443

```python { .api }

444

class Client:

445

def create_stack_component(

446

self,

447

name: str,

448

flavor: str,

449

component_type: str,

450

configuration: dict,

451

connector: str = None

452

):

453

"""

454

Create a new stack component.

455

456

Parameters:

457

- name: Component name

458

- flavor: Flavor name

459

- component_type: Component type (from StackComponentType enum)

460

- configuration: Component configuration dict

461

- connector: Service connector name/ID (optional)

462

463

Returns:

464

ComponentResponse: Created component

465

"""

466

467

def get_stack_component(

468

self,

469

name_or_id: str,

470

component_type: str = None

471

):

472

"""

473

Get stack component by name/ID/type.

474

475

Parameters:

476

- name_or_id: Component name or UUID

477

- component_type: Component type (from StackComponentType enum)

478

479

Returns:

480

ComponentResponse: Component information

481

"""

482

483

def list_stack_components(

484

self,

485

name: str = None,

486

type: str = None,

487

flavor_name: str = None,

488

**kwargs

489

):

490

"""

491

List stack components.

492

493

Parameters:

494

- name: Filter by name

495

- type: Filter by component type

496

- flavor_name: Filter by flavor

497

- **kwargs: Additional filter parameters

498

499

Returns:

500

Page[ComponentResponse]: Paginated list of components

501

"""

502

503

def update_stack_component(

504

self,

505

name_or_id: str,

506

component_type: str = None,

507

updated_name: str = None,

508

updated_configuration: dict = None,

509

updated_connector: str = None

510

):

511

"""

512

Update stack component.

513

514

Parameters:

515

- name_or_id: Component name or UUID

516

- component_type: Component type

517

- updated_name: New component name

518

- updated_configuration: Updated configuration

519

- updated_connector: Updated connector

520

521

Returns:

522

ComponentResponse: Updated component

523

"""

524

525

def delete_stack_component(

526

self,

527

name_or_id: str,

528

component_type: str = None

529

):

530

"""

531

Delete stack component.

532

533

Parameters:

534

- name_or_id: Component name or UUID

535

- component_type: Component type

536

"""

537

```

538

539

### Flavor Management

540

541

```python { .api }

542

class Client:

543

def create_flavor(

544

self,

545

source: str,

546

component_type: str

547

):

548

"""

549

Register a custom flavor.

550

551

Parameters:

552

- source: Python source path (e.g., "my_module.MyFlavor")

553

- component_type: Component type (from StackComponentType enum)

554

555

Returns:

556

FlavorResponse: Created flavor

557

"""

558

559

def get_flavor(self, name_or_id: str):

560

"""

561

Get flavor by name or ID.

562

563

Parameters:

564

- name_or_id: Flavor name or UUID

565

566

Returns:

567

FlavorResponse: Flavor information

568

"""

569

570

def list_flavors(

571

self,

572

name: str = None,

573

type: str = None,

574

**kwargs

575

):

576

"""

577

List all flavors.

578

579

Parameters:

580

- name: Filter by name

581

- type: Filter by component type

582

- **kwargs: Additional filter parameters

583

584

Returns:

585

Page[FlavorResponse]: Paginated list of flavors

586

"""

587

588

def delete_flavor(self, name_or_id: str):

589

"""

590

Delete a flavor.

591

592

Parameters:

593

- name_or_id: Flavor name or UUID

594

"""

595

596

def get_flavors_by_type(self, component_type: str):

597

"""

598

Get flavors for a component type.

599

600

Parameters:

601

- component_type: Component type (from StackComponentType enum)

602

603

Returns:

604

Page[FlavorResponse]: List of flavors for the type

605

"""

606

607

def get_flavor_by_name_and_type(

608

self,

609

name: str,

610

component_type: str

611

):

612

"""

613

Get specific flavor by name and type.

614

615

Parameters:

616

- name: Flavor name

617

- component_type: Component type

618

619

Returns:

620

FlavorResponse: Flavor information

621

"""

622

```

623

624

### Pipeline Management

625

626

```python { .api }

627

class Client:

628

def list_pipelines(

629

self,

630

name: str = None,

631

**kwargs

632

):

633

"""

634

List all pipelines.

635

636

Parameters:

637

- name: Filter by name

638

- **kwargs: Additional filter parameters

639

640

Returns:

641

Page[PipelineResponse]: Paginated list of pipelines

642

"""

643

644

def get_pipeline(self, name_or_id: str):

645

"""

646

Get pipeline by name or ID.

647

648

Parameters:

649

- name_or_id: Pipeline name or UUID

650

651

Returns:

652

PipelineResponse: Pipeline information

653

"""

654

655

def delete_pipeline(self, name_or_id: str):

656

"""

657

Delete a pipeline.

658

659

Parameters:

660

- name_or_id: Pipeline name or UUID

661

"""

662

663

def trigger_pipeline(

664

self,

665

name_or_id: str,

666

run_config: dict = None,

667

**kwargs

668

):

669

"""

670

Trigger a pipeline run.

671

672

Parameters:

673

- name_or_id: Pipeline name or UUID

674

- run_config: Run configuration dict

675

- **kwargs: Additional parameters

676

677

Returns:

678

PipelineRunResponse: Created pipeline run

679

"""

680

```

681

682

### Pipeline Run Management

683

684

```python { .api }

685

class Client:

686

def get_pipeline_run(self, name_or_id: str):

687

"""

688

Get pipeline run by ID.

689

690

Parameters:

691

- name_or_id: Pipeline run UUID or name

692

693

Returns:

694

PipelineRunResponse: Pipeline run details

695

"""

696

697

def list_pipeline_runs(

698

self,

699

pipeline_id: str = None,

700

name: str = None,

701

status: str = None,

702

**kwargs

703

):

704

"""

705

List pipeline runs.

706

707

Parameters:

708

- pipeline_id: Filter by pipeline UUID

709

- name: Filter by run name

710

- status: Filter by execution status

711

- **kwargs: Additional filter parameters

712

713

Returns:

714

Page[PipelineRunResponse]: Paginated list of runs

715

"""

716

717

def delete_pipeline_run(self, name_or_id: str):

718

"""

719

Delete a pipeline run.

720

721

Parameters:

722

- name_or_id: Pipeline run UUID or name

723

"""

724

```

725

726

### Step Run Management

727

728

```python { .api }

729

class Client:

730

def get_run_step(self, step_run_id: str):

731

"""

732

Get step run by ID.

733

734

Parameters:

735

- step_run_id: Step run UUID

736

737

Returns:

738

StepRunResponse: Step run details

739

"""

740

741

def list_run_steps(

742

self,

743

pipeline_run_id: str = None,

744

name: str = None,

745

**kwargs

746

):

747

"""

748

List step runs.

749

750

Parameters:

751

- pipeline_run_id: Filter by pipeline run UUID

752

- name: Filter by step name

753

- **kwargs: Additional filter parameters

754

755

Returns:

756

Page[StepRunResponse]: Paginated list of step runs

757

"""

758

```

759

760

### Artifact Management

761

762

```python { .api }

763

class Client:

764

def get_artifact(self, name_or_id: str):

765

"""

766

Get artifact by name or ID.

767

768

Parameters:

769

- name_or_id: Artifact name or UUID

770

771

Returns:

772

ArtifactResponse: Artifact information

773

"""

774

775

def list_artifacts(

776

self,

777

name: str = None,

778

tag: str = None,

779

**kwargs

780

):

781

"""

782

List artifacts.

783

784

Parameters:

785

- name: Filter by name

786

- tag: Filter by tag

787

- **kwargs: Additional filter parameters

788

789

Returns:

790

Page[ArtifactResponse]: Paginated list of artifacts

791

"""

792

793

def update_artifact(

794

self,

795

name_or_id: str,

796

updated_name: str = None,

797

add_tags: list = None,

798

remove_tags: list = None

799

):

800

"""

801

Update artifact.

802

803

Parameters:

804

- name_or_id: Artifact name or UUID

805

- updated_name: New artifact name

806

- add_tags: Tags to add

807

- remove_tags: Tags to remove

808

809

Returns:

810

ArtifactResponse: Updated artifact

811

"""

812

813

def delete_artifact(self, name_or_id: str):

814

"""

815

Delete artifact.

816

817

Parameters:

818

- name_or_id: Artifact name or UUID

819

"""

820

821

def prune_artifacts(self, only_versions: bool = True):

822

"""

823

Prune unused artifacts.

824

825

Parameters:

826

- only_versions: Only delete unused versions (default: True)

827

828

Returns:

829

int: Number of artifacts/versions deleted

830

"""

831

```

832

833

### Artifact Version Management

834

835

```python { .api }

836

class Client:

837

def get_artifact_version(

838

self,

839

name_or_id: str,

840

version: str = None

841

):

842

"""

843

Get artifact version.

844

845

Parameters:

846

- name_or_id: Artifact name or version UUID

847

- version: Version identifier (latest if None)

848

849

Returns:

850

ArtifactVersionResponse: Artifact version details

851

"""

852

853

def list_artifact_versions(

854

self,

855

name: str = None,

856

artifact_id: str = None,

857

**kwargs

858

):

859

"""

860

List artifact versions.

861

862

Parameters:

863

- name: Filter by artifact name

864

- artifact_id: Filter by artifact UUID

865

- **kwargs: Additional filter parameters

866

867

Returns:

868

Page[ArtifactVersionResponse]: Paginated list of versions

869

"""

870

871

def update_artifact_version(

872

self,

873

name_or_id: str,

874

version: str = None,

875

add_tags: list = None,

876

remove_tags: list = None

877

):

878

"""

879

Update artifact version.

880

881

Parameters:

882

- name_or_id: Artifact name or version UUID

883

- version: Version identifier

884

- add_tags: Tags to add

885

- remove_tags: Tags to remove

886

887

Returns:

888

ArtifactVersionResponse: Updated version

889

"""

890

891

def delete_artifact_version(

892

self,

893

name_or_id: str,

894

version: str = None

895

):

896

"""

897

Delete artifact version.

898

899

Parameters:

900

- name_or_id: Artifact name or version UUID

901

- version: Version identifier

902

"""

903

```

904

905

### Model Management

906

907

```python { .api }

908

class Client:

909

def create_model(

910

self,

911

name: str,

912

license: str = None,

913

description: str = None,

914

tags: list = None

915

):

916

"""

917

Create model namespace.

918

919

Parameters:

920

- name: Model name

921

- license: License identifier

922

- description: Model description

923

- tags: List of tags

924

925

Returns:

926

ModelResponse: Created model

927

"""

928

929

def get_model(self, name_or_id: str):

930

"""

931

Get model by name or ID.

932

933

Parameters:

934

- name_or_id: Model name or UUID

935

936

Returns:

937

ModelResponse: Model information

938

"""

939

940

def list_models(

941

self,

942

name: str = None,

943

tag: str = None,

944

**kwargs

945

):

946

"""

947

List models.

948

949

Parameters:

950

- name: Filter by name

951

- tag: Filter by tag

952

- **kwargs: Additional filter parameters

953

954

Returns:

955

Page[ModelResponse]: Paginated list of models

956

"""

957

958

def update_model(

959

self,

960

name_or_id: str,

961

updated_name: str = None,

962

updated_license: str = None,

963

updated_description: str = None,

964

add_tags: list = None,

965

remove_tags: list = None

966

):

967

"""

968

Update model.

969

970

Parameters:

971

- name_or_id: Model name or UUID

972

- updated_name: New model name

973

- updated_license: New license

974

- updated_description: New description

975

- add_tags: Tags to add

976

- remove_tags: Tags to remove

977

978

Returns:

979

ModelResponse: Updated model

980

"""

981

982

def delete_model(self, name_or_id: str):

983

"""

984

Delete model.

985

986

Parameters:

987

- name_or_id: Model name or UUID

988

"""

989

```

990

991

### Model Version Management

992

993

```python { .api }

994

class Client:

995

def create_model_version(

996

self,

997

model_name_or_id: str,

998

version: str = None,

999

description: str = None,

1000

tags: list = None

1001

):

1002

"""

1003

Create model version.

1004

1005

Parameters:

1006

- model_name_or_id: Model name or UUID

1007

- version: Version identifier

1008

- description: Version description

1009

- tags: List of tags

1010

1011

Returns:

1012

ModelVersionResponse: Created model version

1013

"""

1014

1015

def get_model_version(

1016

self,

1017

model_name_or_id: str,

1018

version: str = None

1019

):

1020

"""

1021

Get model version.

1022

1023

Parameters:

1024

- model_name_or_id: Model name or UUID

1025

- version: Version identifier or stage name

1026

1027

Returns:

1028

ModelVersionResponse: Model version details

1029

"""

1030

1031

def list_model_versions(

1032

self,

1033

model_name_or_id: str = None,

1034

stage: str = None,

1035

**kwargs

1036

):

1037

"""

1038

List model versions.

1039

1040

Parameters:

1041

- model_name_or_id: Filter by model name or UUID

1042

- stage: Filter by stage

1043

- **kwargs: Additional filter parameters

1044

1045

Returns:

1046

Page[ModelVersionResponse]: Paginated list of versions

1047

"""

1048

1049

def update_model_version(

1050

self,

1051

model_name_or_id: str,

1052

version_name_or_id: str,

1053

stage: str = None,

1054

description: str = None,

1055

add_tags: list = None,

1056

remove_tags: list = None

1057

):

1058

"""

1059

Update model version.

1060

1061

Parameters:

1062

- model_name_or_id: Model name or UUID

1063

- version_name_or_id: Version name or UUID

1064

- stage: New stage

1065

- description: New description

1066

- add_tags: Tags to add

1067

- remove_tags: Tags to remove

1068

1069

Returns:

1070

ModelVersionResponse: Updated version

1071

"""

1072

1073

def delete_model_version(

1074

self,

1075

model_name_or_id: str,

1076

version_name_or_id: str

1077

):

1078

"""

1079

Delete model version.

1080

1081

Parameters:

1082

- model_name_or_id: Model name or UUID

1083

- version_name_or_id: Version name or UUID

1084

"""

1085

1086

def list_model_version_artifact_links(

1087

self,

1088

model_version_id: str

1089

):

1090

"""

1091

List artifact links for model version.

1092

1093

Parameters:

1094

- model_version_id: Model version UUID

1095

1096

Returns:

1097

Page[ModelVersionArtifactResponse]: List of artifact links

1098

"""

1099

1100

def delete_model_version_artifact_link(

1101

self,

1102

model_version_id: str,

1103

artifact_version_id: str

1104

):

1105

"""

1106

Delete artifact link from model version.

1107

1108

Parameters:

1109

- model_version_id: Model version UUID

1110

- artifact_version_id: Artifact version UUID

1111

"""

1112

1113

def list_model_version_pipeline_run_links(

1114

self,

1115

model_version_id: str

1116

):

1117

"""

1118

List pipeline run links for model version.

1119

1120

Parameters:

1121

- model_version_id: Model version UUID

1122

1123

Returns:

1124

Page[ModelVersionPipelineRunResponse]: List of pipeline run links

1125

"""

1126

```

1127

1128

### Secret Management

1129

1130

```python { .api }

1131

class Client:

1132

def create_secret(

1133

self,

1134

name: str,

1135

values: dict,

1136

scope: str = "project"

1137

):

1138

"""

1139

Create a new secret.

1140

1141

Parameters:

1142

- name: Secret name

1143

- values: Secret values dict

1144

- scope: Secret scope ("project" or "user")

1145

1146

Returns:

1147

SecretResponse: Created secret

1148

"""

1149

1150

def get_secret(self, name_or_id: str):

1151

"""

1152

Get secret by name or ID.

1153

1154

Parameters:

1155

- name_or_id: Secret name or UUID

1156

1157

Returns:

1158

SecretResponse: Secret information (values not included)

1159

"""

1160

1161

def list_secrets(

1162

self,

1163

name: str = None,

1164

scope: str = None,

1165

**kwargs

1166

):

1167

"""

1168

List secrets.

1169

1170

Parameters:

1171

- name: Filter by name

1172

- scope: Filter by scope

1173

- **kwargs: Additional filter parameters

1174

1175

Returns:

1176

Page[SecretResponse]: Paginated list of secrets

1177

"""

1178

1179

def update_secret(

1180

self,

1181

name_or_id: str,

1182

updated_name: str = None,

1183

updated_values: dict = None,

1184

updated_scope: str = None

1185

):

1186

"""

1187

Update secret.

1188

1189

Parameters:

1190

- name_or_id: Secret name or UUID

1191

- updated_name: New secret name

1192

- updated_values: Updated values

1193

- updated_scope: Updated scope

1194

1195

Returns:

1196

SecretResponse: Updated secret

1197

"""

1198

1199

def delete_secret(self, name_or_id: str):

1200

"""

1201

Delete secret.

1202

1203

Parameters:

1204

- name_or_id: Secret name or UUID

1205

"""

1206

1207

def backup_secrets(

1208

self,

1209

ignore_errors: bool = True,

1210

delete_secrets: bool = False

1211

):

1212

"""

1213

Backup secrets.

1214

1215

Parameters:

1216

- ignore_errors: Continue on errors

1217

- delete_secrets: Delete after backup

1218

1219

Returns:

1220

dict: Backup data

1221

"""

1222

1223

def restore_secrets(

1224

self,

1225

backup: dict,

1226

ignore_errors: bool = False

1227

):

1228

"""

1229

Restore secrets from backup.

1230

1231

Parameters:

1232

- backup: Backup data dict

1233

- ignore_errors: Continue on errors

1234

"""

1235

```

1236

1237

### Service Connector Management

1238

1239

```python { .api }

1240

class Client:

1241

def create_service_connector(

1242

self,

1243

name: str,

1244

type: str,

1245

auth_method: str,

1246

configuration: dict,

1247

resource_types: list = None

1248

):

1249

"""

1250

Create service connector.

1251

1252

Parameters:

1253

- name: Connector name

1254

- type: Connector type

1255

- auth_method: Authentication method

1256

- configuration: Configuration dict

1257

- resource_types: List of resource types

1258

1259

Returns:

1260

ServiceConnectorResponse: Created connector

1261

"""

1262

1263

def get_service_connector(self, name_or_id: str):

1264

"""

1265

Get service connector.

1266

1267

Parameters:

1268

- name_or_id: Connector name or UUID

1269

1270

Returns:

1271

ServiceConnectorResponse: Connector information

1272

"""

1273

1274

def list_service_connectors(

1275

self,

1276

name: str = None,

1277

connector_type: str = None,

1278

**kwargs

1279

):

1280

"""

1281

List service connectors.

1282

1283

Parameters:

1284

- name: Filter by name

1285

- connector_type: Filter by type

1286

- **kwargs: Additional filter parameters

1287

1288

Returns:

1289

Page[ServiceConnectorResponse]: Paginated list of connectors

1290

"""

1291

1292

def update_service_connector(

1293

self,

1294

name_or_id: str,

1295

updated_name: str = None,

1296

updated_configuration: dict = None

1297

):

1298

"""

1299

Update service connector.

1300

1301

Parameters:

1302

- name_or_id: Connector name or UUID

1303

- updated_name: New connector name

1304

- updated_configuration: Updated configuration

1305

1306

Returns:

1307

ServiceConnectorResponse: Updated connector

1308

"""

1309

1310

def delete_service_connector(self, name_or_id: str):

1311

"""

1312

Delete service connector.

1313

1314

Parameters:

1315

- name_or_id: Connector name or UUID

1316

"""

1317

1318

def verify_service_connector(

1319

self,

1320

name_or_id: str,

1321

resource_type: str = None,

1322

resource_id: str = None

1323

):

1324

"""

1325

Verify connector credentials.

1326

1327

Parameters:

1328

- name_or_id: Connector name or UUID

1329

- resource_type: Resource type to verify

1330

- resource_id: Resource ID to verify

1331

1332

Returns:

1333

ServiceConnectorResourcesModel: Verification results

1334

"""

1335

1336

def get_service_connector_client(

1337

self,

1338

name_or_id: str,

1339

resource_type: str = None,

1340

resource_id: str = None

1341

):

1342

"""

1343

Get connector client.

1344

1345

Parameters:

1346

- name_or_id: Connector name or UUID

1347

- resource_type: Resource type

1348

- resource_id: Resource ID

1349

1350

Returns:

1351

Client object for the connector

1352

"""

1353

1354

def list_service_connector_resources(

1355

self,

1356

connector_type: str = None,

1357

resource_type: str = None

1358

):

1359

"""

1360

List connector resources.

1361

1362

Parameters:

1363

- connector_type: Filter by connector type

1364

- resource_type: Filter by resource type

1365

1366

Returns:

1367

list: List of available resources

1368

"""

1369

1370

def list_service_connector_types(self):

1371

"""

1372

List connector types.

1373

1374

Returns:

1375

list[ServiceConnectorTypeModel]: Available connector types

1376

"""

1377

1378

def get_service_connector_type(self, connector_type: str):

1379

"""

1380

Get connector type.

1381

1382

Parameters:

1383

- connector_type: Connector type identifier

1384

1385

Returns:

1386

ServiceConnectorTypeModel: Connector type details

1387

"""

1388

```

1389

1390

### Tag Management

1391

1392

```python { .api }

1393

class Client:

1394

def create_tag(

1395

self,

1396

name: str,

1397

color: str = None

1398

):

1399

"""

1400

Create tag.

1401

1402

Parameters:

1403

- name: Tag name

1404

- color: Tag color (from ColorVariants enum)

1405

1406

Returns:

1407

TagResponse: Created tag

1408

"""

1409

1410

def get_tag(self, name_or_id: str):

1411

"""

1412

Get tag.

1413

1414

Parameters:

1415

- name_or_id: Tag name or UUID

1416

1417

Returns:

1418

TagResponse: Tag information

1419

"""

1420

1421

def list_tags(

1422

self,

1423

name: str = None,

1424

**kwargs

1425

):

1426

"""

1427

List tags.

1428

1429

Parameters:

1430

- name: Filter by name

1431

- **kwargs: Additional filter parameters

1432

1433

Returns:

1434

Page[TagResponse]: Paginated list of tags

1435

"""

1436

1437

def update_tag(

1438

self,

1439

name_or_id: str,

1440

updated_name: str = None,

1441

updated_color: str = None

1442

):

1443

"""

1444

Update tag.

1445

1446

Parameters:

1447

- name_or_id: Tag name or UUID

1448

- updated_name: New tag name

1449

- updated_color: New color

1450

1451

Returns:

1452

TagResponse: Updated tag

1453

"""

1454

1455

def delete_tag(self, name_or_id: str):

1456

"""

1457

Delete tag.

1458

1459

Parameters:

1460

- name_or_id: Tag name or UUID

1461

"""

1462

```

1463

1464

### Additional Client Methods

1465

1466

The Client class includes 100+ methods total. Additional methods include:

1467

1468

- **Code Repository Management**: `create_code_repository()`, `get_code_repository()`, `list_code_repositories()`, `update_code_repository()`, `delete_code_repository()`

1469

- **Build Management**: `get_build()`, `list_builds()`, `delete_build()`

1470

- **Schedule Management**: `get_schedule()`, `list_schedules()`, `update_schedule()`, `delete_schedule()`

1471

- **Deployment Management**: `get_deployment()`, `list_deployments()`, `provision_deployment()`, `deprovision_deployment()`, `delete_deployment()`, `get_deployment_logs()`

1472

- **Run Template Management**: `create_run_template()`, `get_run_template()`, `list_run_templates()`, `update_run_template()`, `delete_run_template()`

1473

- **Service Management**: `create_service()`, `get_service()`, `list_services()`, `update_service()`, `delete_service()`

1474

- **Event Source Management**: `create_event_source()`, `get_event_source()`, `list_event_sources()`, `update_event_source()`, `delete_event_source()`

1475

- **Action Management**: `create_action()`, `get_action()`, `list_actions()`, `update_action()`, `delete_action()`

1476

- **Trigger Management**: `create_trigger()`, `get_trigger()`, `list_triggers()`, `update_trigger()`, `delete_trigger()`

1477

- **Trigger Execution**: `get_trigger_execution()`, `list_trigger_executions()`, `delete_trigger_execution()`

1478

- **Service Account Management**: `create_service_account()`, `get_service_account()`, `list_service_accounts()`, `update_service_account()`, `delete_service_account()`

1479

- **API Key Management**: `create_api_key()`, `get_api_key()`, `list_api_keys()`, `update_api_key()`, `rotate_api_key()`, `delete_api_key()`, `set_api_key()`

1480

- **Device Authorization**: `list_authorized_devices()`, `get_authorized_device()`, `update_authorized_device()`, `delete_authorized_device()`

1481

- **Server Settings**: `get_settings()`, `update_server_settings()`

1482

- **Metadata**: `create_run_metadata()`

1483

1484

## Usage Examples

1485

1486

### Basic Client Usage

1487

1488

```python

1489

from zenml.client import Client

1490

1491

# Get client instance (singleton)

1492

client = Client()

1493

1494

# Access active resources

1495

print(f"Active stack: {client.active_stack_model.name}")

1496

print(f"Active project: {client.active_project.name}")

1497

print(f"Active user: {client.active_user.name}")

1498

1499

# Initialize a new repository

1500

Client.initialize(root="/path/to/project")

1501

```

1502

1503

### Managing Stacks

1504

1505

```python

1506

from zenml.client import Client

1507

1508

client = Client()

1509

1510

# Create a stack

1511

stack = client.create_stack(

1512

name="aws_stack",

1513

components={

1514

"orchestrator": "sagemaker_orchestrator",

1515

"artifact_store": "s3_artifact_store",

1516

"container_registry": "ecr_registry"

1517

},

1518

description="AWS production stack"

1519

)

1520

1521

# List all stacks

1522

stacks = client.list_stacks()

1523

for s in stacks:

1524

print(f"Stack: {s.name}")

1525

1526

# Switch active stack

1527

client.activate_stack("aws_stack")

1528

1529

# Update stack

1530

client.update_stack(

1531

name_or_id="aws_stack",

1532

updated_description="Updated AWS stack"

1533

)

1534

```

1535

1536

### Working with Pipeline Runs

1537

1538

```python

1539

from zenml.client import Client

1540

1541

client = Client()

1542

1543

# Get latest pipeline run

1544

runs = client.list_pipeline_runs(

1545

pipeline_id=client.get_pipeline("training_pipeline").id,

1546

sort_by="created",

1547

size=1

1548

)

1549

latest_run = runs.items[0]

1550

1551

# Get run details

1552

print(f"Run: {latest_run.name}")

1553

print(f"Status: {latest_run.status}")

1554

print(f"Start time: {latest_run.start_time}")

1555

1556

# List steps in the run

1557

steps = client.list_run_steps(pipeline_run_id=latest_run.id)

1558

for step in steps:

1559

print(f"Step: {step.name}, Status: {step.status}")

1560

1561

# Get step outputs

1562

step = steps.items[0]

1563

outputs = step.outputs

1564

for name, artifact in outputs.items():

1565

print(f"Output '{name}': {artifact.uri}")

1566

```

1567

1568

### Managing Models

1569

1570

```python

1571

from zenml.client import Client

1572

from zenml.enums import ModelStages

1573

1574

client = Client()

1575

1576

# Create model

1577

model = client.create_model(

1578

name="fraud_detector",

1579

license="MIT",

1580

description="Fraud detection model",

1581

tags=["fraud", "classification"]

1582

)

1583

1584

# Create version

1585

version = client.create_model_version(

1586

model_name_or_id=model.id,

1587

version="1.0.0",

1588

description="Initial release"

1589

)

1590

1591

# Promote to production

1592

client.update_model_version(

1593

model_name_or_id=model.id,

1594

version_name_or_id=version.id,

1595

stage=ModelStages.PRODUCTION

1596

)

1597

1598

# Get production version

1599

prod_version = client.get_model_version(

1600

model_name_or_id="fraud_detector",

1601

version=ModelStages.PRODUCTION

1602

)

1603

print(f"Production version: {prod_version.version}")

1604

```

1605

1606

### Managing Secrets

1607

1608

```python

1609

from zenml.client import Client

1610

1611

client = Client()

1612

1613

# Create secret

1614

secret = client.create_secret(

1615

name="aws_credentials",

1616

values={

1617

"aws_access_key_id": "AKIA...",

1618

"aws_secret_access_key": "secret..."

1619

},

1620

scope="project"

1621

)

1622

1623

# List secrets (values not returned)

1624

secrets = client.list_secrets()

1625

for s in secrets:

1626

print(f"Secret: {s.name}")

1627

1628

# Update secret

1629

client.update_secret(

1630

name_or_id="aws_credentials",

1631

updated_values={

1632

"aws_access_key_id": "AKIA_NEW...",

1633

"aws_secret_access_key": "new_secret..."

1634

}

1635

)

1636

1637

# Backup and restore

1638

backup = client.backup_secrets()

1639

# ... later ...

1640

client.restore_secrets(backup)

1641

```

1642