0
# Multi-language Support
1
2
Identical APIs across Python, Go, JavaScript/TypeScript, and Rust with language-specific client utilities, authentication support, and idiomatic patterns. The multi-language support ensures consistent developer experience while providing language-specific optimizations and idioms.
3
4
## Capabilities
5
6
### Python Client Support
7
8
Comprehensive Python client with protobuf message classes and gRPC service stubs.
9
10
```python { .api }
11
# Core imports for Python
12
from flyteidl.core import literals_pb2, tasks_pb2, workflow_pb2, types_pb2, identifier_pb2
13
from flyteidl.admin import task_pb2, workflow_pb2, execution_pb2, project_pb2
14
from flyteidl.service import admin_pb2_grpc, dataproxy_pb2_grpc, auth_pb2_grpc
15
16
# Service client creation
17
import grpc
18
from flyteidl.service.admin_pb2_grpc import AdminServiceStub
19
20
def create_admin_client(endpoint: str) -> AdminServiceStub:
21
"""Create gRPC admin client."""
22
channel = grpc.insecure_channel(endpoint)
23
return AdminServiceStub(channel)
24
25
# Plugin imports
26
from flyteidl.plugins import spark_pb2, pytorch_pb2, array_job_pb2, dask_pb2
27
from flyteidl.plugins.kubeflow import tensorflow_pb2, mpi_pb2
28
29
# Data management imports
30
from flyteidl.datacatalog import datacatalog_pb2
31
from flyteidl.cacheservice import cacheservice_pb2
32
```
33
34
### Go Client Support
35
36
Rich Go client libraries with authentication, configuration management, and idiomatic patterns.
37
38
```go { .api }
39
// Core imports for Go
40
import (
41
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
42
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin"
43
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service"
44
"github.com/flyteorg/flyte/flyteidl/clients/go/admin"
45
)
46
47
// AdminClient interface with rich functionality
48
type AdminClient interface {
49
CreateTask(ctx context.Context, request *admin.TaskCreateRequest) (*admin.TaskCreateResponse, error)
50
GetTask(ctx context.Context, request *admin.ObjectGetRequest) (*admin.Task, error)
51
ListTasks(ctx context.Context, request *admin.ResourceListRequest) (*admin.TaskList, error)
52
CreateWorkflow(ctx context.Context, request *admin.WorkflowCreateRequest) (*admin.WorkflowCreateResponse, error)
53
CreateExecution(ctx context.Context, request *admin.ExecutionCreateRequest) (*admin.ExecutionCreateResponse, error)
54
GetExecution(ctx context.Context, request *admin.WorkflowExecutionGetRequest) (*admin.Execution, error)
55
ListExecutions(ctx context.Context, request *admin.ResourceListRequest) (*admin.ExecutionList, error)
56
TerminateExecution(ctx context.Context, request *admin.ExecutionTerminateRequest) (*admin.ExecutionTerminateResponse, error)
57
}
58
59
// Client factory function
60
func NewAdminClient(ctx context.Context, cfg *Config) (AdminClient, error)
61
62
// Configuration management
63
type Config struct {
64
Endpoint string
65
UseInsecure bool
66
MaxRetries int
67
PerRetryTimeout time.Duration
68
Credentials Credentials
69
}
70
71
// Authentication support
72
type Credentials struct {
73
ClientID string
74
ClientSecret string
75
AuthorizeURL string
76
TokenURL string
77
RedirectURL string
78
Scopes []string
79
UseAudienceFromAdmin bool
80
}
81
```
82
83
### Go Authentication Utilities
84
85
Advanced OAuth2 authentication with token management and device flow support.
86
87
```go { .api }
88
// Token orchestrator for OAuth2 flows
89
type TokenOrchestrator interface {
90
FetchTokenFromCacheOrRefreshIt(ctx context.Context) (*oauth2.Token, error)
91
FetchTokenFromRefreshFlow(ctx context.Context) (*oauth2.Token, error)
92
FetchTokenFromClientCredentialsFlow(ctx context.Context) (*oauth2.Token, error)
93
FetchTokenFromDeviceFlow(ctx context.Context) (*oauth2.Token, error)
94
}
95
96
// Device flow support
97
type DeviceFlowTokenSource struct {
98
cfg *oauth2.Config
99
tokenURL string
100
audience string
101
httpClient *http.Client
102
}
103
104
// PKCE (Proof Key for Code Exchange) support
105
type PKCETokenSource struct {
106
cfg *oauth2.Config
107
verifier string
108
authURL string
109
httpClient *http.Client
110
}
111
112
// Certificate handling for mTLS
113
type CertificateManager interface {
114
GetClientCertificate() (tls.Certificate, error)
115
GetRootCAs() (*x509.CertPool, error)
116
}
117
```
118
119
### Go Client Utilities
120
121
Helper functions and utilities for working with Flyte types and data structures.
122
123
```go { .api }
124
// Literal utilities for type conversion
125
func MakeLiteral(v interface{}) (*core.Literal, error)
126
func ExtractFromLiteral(lit *core.Literal) (interface{}, error)
127
func MakeLiteralForType(t *core.LiteralType, v interface{}) (*core.Literal, error)
128
129
// Identifier utilities
130
func MakeIdentifier(resourceType core.ResourceType, project, domain, name, version string) *core.Identifier
131
func MakeWorkflowExecutionIdentifier(project, domain, name string) *core.WorkflowExecutionIdentifier
132
133
// Type utilities
134
func MakePrimitive(v interface{}) (*core.Primitive, error)
135
func MakeScalar(v interface{}) (*core.Scalar, error)
136
func MakeLiteralType(t reflect.Type) (*core.LiteralType, error)
137
138
// Interface utilities
139
func MakeTypedInterface(inputs, outputs map[string]*core.LiteralType) *core.TypedInterface
140
func MakeVariable(t *core.LiteralType, description string) *core.Variable
141
```
142
143
### JavaScript/TypeScript Support
144
145
Modern TypeScript support with Connect-style clients and full type definitions.
146
147
```typescript { .api }
148
// Core imports for TypeScript
149
import { AdminServiceClient } from '@flyteorg/flyteidl/service/admin_connect';
150
import { Task, Workflow, Execution } from '@flyteorg/flyteidl/admin/admin_pb';
151
import { Literal, LiteralType, LiteralMap } from '@flyteorg/flyteidl/core/literals_pb';
152
import { Identifier, ResourceType } from '@flyteorg/flyteidl/core/identifier_pb';
153
import { TaskTemplate, WorkflowTemplate } from '@flyteorg/flyteidl/core/tasks_pb';
154
155
// Client creation with transport
156
import { createGrpcWebTransport } from "@connectrpc/connect-web";
157
158
function createAdminClient(baseUrl: string): AdminServiceClient {
159
const transport = createGrpcWebTransport({
160
baseUrl,
161
credentials: "include",
162
});
163
return new AdminServiceClient(transport);
164
}
165
166
// Plugin type imports
167
import { SparkJob } from '@flyteorg/flyteidl/plugins/spark_pb';
168
import { PyTorchJob } from '@flyteorg/flyteidl/plugins/kubeflow/pytorch_pb';
169
import { ArrayJob } from '@flyteorg/flyteidl/plugins/array_job_pb';
170
171
// Data management imports
172
import { Dataset, Artifact } from '@flyteorg/flyteidl/datacatalog/datacatalog_pb';
173
```
174
175
### TypeScript Type Definitions
176
177
Complete TypeScript definitions with proper type safety and IntelliSense support.
178
179
```typescript { .api }
180
// Literal type utilities
181
interface LiteralValue {
182
scalar?: Scalar;
183
collection?: LiteralCollection;
184
map?: LiteralMap;
185
}
186
187
interface LiteralTypeDefinition {
188
simple?: SimpleType;
189
blob?: BlobType;
190
collection_type?: LiteralType;
191
map_value_type?: LiteralType;
192
schema?: SchemaType;
193
structured_dataset_type?: StructuredDatasetType;
194
union_type?: UnionType;
195
}
196
197
// Client configuration
198
interface ClientConfig {
199
endpoint: string;
200
credentials?: RequestCredentials;
201
timeout?: number;
202
retries?: number;
203
}
204
205
// Authentication configuration
206
interface AuthConfig {
207
clientId: string;
208
clientSecret?: string;
209
authUrl: string;
210
tokenUrl: string;
211
scopes: string[];
212
}
213
```
214
215
### Rust Support
216
217
Rust crate with Tonic gRPC support and idiomatic Rust patterns.
218
219
```rust { .api }
220
// Core imports for Rust
221
use flyteidl::flyteidl::core::{Literal, LiteralType, Identifier, TaskTemplate, WorkflowTemplate};
222
use flyteidl::flyteidl::admin::{Task, Workflow, Execution, AdminServiceClient};
223
use flyteidl::flyteidl::service::admin::admin_service_client::AdminServiceClient;
224
225
// Client creation with tonic
226
use tonic::transport::Channel;
227
use tonic::Request;
228
229
pub async fn create_admin_client(endpoint: String) -> Result<AdminServiceClient<Channel>, Box<dyn std::error::Error>> {
230
let channel = Channel::from_shared(endpoint)?
231
.connect()
232
.await?;
233
Ok(AdminServiceClient::new(channel))
234
}
235
236
// Plugin imports
237
use flyteidl::flyteidl::plugins::{SparkJob, ArrayJob};
238
use flyteidl::flyteidl::plugins::kubeflow::{PyTorchJob, TensorFlowJob};
239
240
// Data management
241
use flyteidl::flyteidl::datacatalog::{Dataset, Artifact, DataCatalogServiceClient};
242
use flyteidl::flyteidl::cacheservice::{CacheServiceClient, GetCacheRequest};
243
```
244
245
### Rust Type Conversions
246
247
Rust-specific utilities for working with protobuf types and conversions.
248
249
```rust { .api }
250
// Literal creation utilities
251
impl Literal {
252
pub fn from_primitive<T>(value: T) -> Self where T: Into<Primitive> { ... }
253
pub fn from_collection(values: Vec<Literal>) -> Self { ... }
254
pub fn from_map(values: std::collections::HashMap<String, Literal>) -> Self { ... }
255
pub fn to_value<T>(&self) -> Result<T, ConversionError> where T: TryFrom<&Literal> { ... }
256
}
257
258
// Identifier creation
259
impl Identifier {
260
pub fn new(resource_type: ResourceType, project: String, domain: String, name: String, version: String) -> Self { ... }
261
pub fn task(project: String, domain: String, name: String, version: String) -> Self { ... }
262
pub fn workflow(project: String, domain: String, name: String, version: String) -> Self { ... }
263
}
264
265
// Error handling
266
#[derive(Debug, thiserror::Error)]
267
pub enum FlyteidlError {
268
#[error("gRPC transport error: {0}")]
269
Transport(#[from] tonic::transport::Error),
270
#[error("gRPC status error: {0}")]
271
Status(#[from] tonic::Status),
272
#[error("Conversion error: {0}")]
273
Conversion(String),
274
}
275
```
276
277
## Language-Specific Usage Examples
278
279
### Python Usage
280
281
```python
282
import grpc
283
from flyteidl.service.admin_pb2_grpc import AdminServiceStub
284
from flyteidl.admin.task_pb2 import TaskCreateRequest
285
from flyteidl.core.identifier_pb2 import Identifier, ResourceType
286
287
# Create client
288
channel = grpc.insecure_channel('localhost:8089')
289
admin_client = AdminServiceStub(channel)
290
291
# Create task identifier
292
task_id = Identifier(
293
resource_type=ResourceType.TASK,
294
project="my-project",
295
domain="development",
296
name="my-task",
297
version="v1.0.0"
298
)
299
300
# Create and register task
301
request = TaskCreateRequest(id=task_id, spec=task_template)
302
response = admin_client.CreateTask(request)
303
```
304
305
### Go Usage
306
307
```go
308
package main
309
310
import (
311
"context"
312
"github.com/flyteorg/flyte/flyteidl/clients/go/admin"
313
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
314
adminpb "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin"
315
)
316
317
func main() {
318
// Create client with authentication
319
cfg := &admin.Config{
320
Endpoint: "flyte.example.com",
321
UseInsecure: false,
322
Credentials: admin.Credentials{
323
ClientID: "flytectl",
324
ClientSecret: "secret",
325
TokenURL: "https://flyte.example.com/oauth2/token",
326
},
327
}
328
329
client, err := admin.NewAdminClient(context.Background(), cfg)
330
if err != nil {
331
panic(err)
332
}
333
334
// Create task identifier
335
taskID := &core.Identifier{
336
ResourceType: core.ResourceType_TASK,
337
Project: "my-project",
338
Domain: "development",
339
Name: "my-task",
340
Version: "v1.0.0",
341
}
342
343
// Get task
344
task, err := client.GetTask(context.Background(), &adminpb.ObjectGetRequest{
345
Id: taskID,
346
})
347
if err != nil {
348
panic(err)
349
}
350
}
351
```
352
353
### TypeScript Usage
354
355
```typescript
356
import { AdminServiceClient } from '@flyteorg/flyteidl/service/admin_connect';
357
import { ObjectGetRequest } from '@flyteorg/flyteidl/admin/admin_pb';
358
import { Identifier, ResourceType } from '@flyteorg/flyteidl/core/identifier_pb';
359
import { createGrpcWebTransport } from "@connectrpc/connect-web";
360
361
// Create client
362
const transport = createGrpcWebTransport({
363
baseUrl: "https://flyte.example.com",
364
credentials: "include",
365
});
366
const adminClient = new AdminServiceClient(transport);
367
368
// Create task identifier
369
const taskId = new Identifier({
370
resourceType: ResourceType.TASK,
371
project: "my-project",
372
domain: "development",
373
name: "my-task",
374
version: "v1.0.0"
375
});
376
377
// Get task
378
const request = new ObjectGetRequest({ id: taskId });
379
const task = await adminClient.getTask(request);
380
```
381
382
### Rust Usage
383
384
```rust
385
use flyteidl::flyteidl::service::admin::admin_service_client::AdminServiceClient;
386
use flyteidl::flyteidl::admin::ObjectGetRequest;
387
use flyteidl::flyteidl::core::{Identifier, ResourceType};
388
use tonic::transport::Channel;
389
390
#[tokio::main]
391
async fn main() -> Result<(), Box<dyn std::error::Error>> {
392
// Create client
393
let channel = Channel::from_static("http://localhost:8089")
394
.connect()
395
.await?;
396
let mut client = AdminServiceClient::new(channel);
397
398
// Create task identifier
399
let task_id = Identifier {
400
resource_type: ResourceType::Task as i32,
401
project: "my-project".to_string(),
402
domain: "development".to_string(),
403
name: "my-task".to_string(),
404
version: "v1.0.0".to_string(),
405
};
406
407
// Get task
408
let request = tonic::Request::new(ObjectGetRequest {
409
id: Some(task_id),
410
});
411
412
let response = client.get_task(request).await?;
413
let task = response.into_inner();
414
415
Ok(())
416
}
417
```
418
419
## Installation and Setup
420
421
### Python Installation
422
423
```bash
424
pip install flyteidl
425
426
# With specific dependencies for gRPC
427
pip install flyteidl[grpc]
428
429
# Development installation
430
pip install flyteidl[dev]
431
```
432
433
### Go Installation
434
435
```bash
436
go get github.com/flyteorg/flyte/flyteidl
437
438
# Import in go.mod
439
require github.com/flyteorg/flyte/flyteidl v1.16.0
440
```
441
442
### JavaScript/TypeScript Installation
443
444
```bash
445
npm install @flyteorg/flyteidl
446
447
# With Connect dependencies
448
npm install @flyteorg/flyteidl @connectrpc/connect @connectrpc/connect-web
449
```
450
451
### Rust Installation
452
453
Add to `Cargo.toml`:
454
455
```toml
456
[dependencies]
457
flyteidl = "1.16.0"
458
tonic = "0.8"
459
prost = "0.11"
460
tokio = { version = "1.0", features = ["full"] }
461
```
462
463
## Cross-Language Compatibility
464
465
All language implementations provide identical API surfaces with:
466
467
- **Protocol Buffer Compatibility**: Identical message structures across languages
468
- **gRPC Service Compatibility**: Same service definitions and method signatures
469
- **Type Safety**: Strong typing with language-appropriate type systems
470
- **Error Handling**: Consistent error codes and handling patterns
471
- **Authentication**: OAuth2 and certificate-based authentication support
472
- **Configuration**: Similar configuration patterns adapted to language conventions