Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orkes Clients SDK methods #228

Merged
merged 136 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
b49a3a8
ai support
v1r3n Oct 6, 2023
27038af
changes
v1r3n Nov 29, 2023
ee8ac83
Merge branch 'main' into prompt_mgmt
v1r3n Nov 29, 2023
e0a0249
Added logging and gracefully terminating workers
coderabhigupta Dec 1, 2023
cbb8983
changes
v1r3n Dec 2, 2023
0737333
update workflow client
v1r3n Dec 2, 2023
e6e5c1e
metadata client
v1r3n Dec 2, 2023
c19afd8
auth client
v1r3n Dec 2, 2023
b189e48
scheduler
v1r3n Dec 2, 2023
28858ab
secrets
v1r3n Dec 2, 2023
319257a
task client
v1r3n Dec 2, 2023
431ecb9
Merge pull request #229 from conductor-sdk/sdk_updates
v1r3n Dec 2, 2023
ec89e76
more changes
v1r3n Dec 2, 2023
d7bda10
more changes
v1r3n Dec 3, 2023
034125a
fixes
v1r3n Dec 3, 2023
397c8d4
more changes
v1r3n Dec 3, 2023
5001e9e
more
v1r3n Dec 3, 2023
69fecb7
fixes
v1r3n Dec 3, 2023
c94042d
Merge pull request #231 from conductor-sdk/prompt_mgmt
v1r3n Dec 3, 2023
2ef7552
Update main.py
v1r3n Dec 3, 2023
cd7ba20
Fixed unit tests
coderabhigupta Dec 3, 2023
5607fe7
metadata clients
v1r3n Dec 3, 2023
6ca03fd
Merge pull request #230 from conductor-sdk/sigkill
v1r3n Dec 3, 2023
a64301d
clean up
v1r3n Dec 3, 2023
be48b6e
clean up
v1r3n Dec 3, 2023
a6fcab0
Update test_async.py
v1r3n Dec 3, 2023
bc7dd82
tests
v1r3n Dec 3, 2023
0a34e7c
tests
v1r3n Dec 3, 2023
6c59e8a
more
v1r3n Dec 4, 2023
1d6ee84
Update ai_orchestrator_example.py
v1r3n Dec 4, 2023
6c87536
task handler updates
v1r3n Dec 5, 2023
a12db91
formatting
v1r3n Dec 5, 2023
f04dc98
changes
v1r3n Dec 10, 2023
337007e
fixes
v1r3n Dec 10, 2023
eb8012c
Update api_client.py
v1r3n Dec 10, 2023
b215a2b
more changes
v1r3n Dec 16, 2023
f856589
Update worker.py
v1r3n Dec 16, 2023
48af2dc
Update setup.py
v1r3n Dec 16, 2023
0291acc
rename
v1r3n Dec 16, 2023
2cdc35e
Update api_client.py
v1r3n Dec 16, 2023
f41a424
even more
v1r3n Dec 16, 2023
efbb435
Update javascript_task.py
v1r3n Dec 16, 2023
7c34f94
fixes
v1r3n Dec 16, 2023
c41a21b
Update test.ipynb
v1r3n Dec 16, 2023
35da4a2
examples
v1r3n Dec 16, 2023
9085b13
compatibility changes
v1r3n Dec 16, 2023
ec94c57
Update worker_task.py
v1r3n Dec 16, 2023
7d55ef6
update
v1r3n Dec 16, 2023
fe1b5e2
Update test_workflow_client.py
v1r3n Dec 17, 2023
3c53a55
readme
v1r3n Dec 17, 2023
6d6f76a
changes
v1r3n Dec 23, 2023
a30508a
fixes
v1r3n Dec 23, 2023
a799453
more changes
v1r3n Dec 23, 2023
800927e
Update test_workflow_client.py
v1r3n Dec 23, 2023
3a48d74
improvements
v1r3n Dec 23, 2023
eed20e9
Update http_task.py
v1r3n Dec 23, 2023
5b12571
Update main.py
v1r3n Dec 23, 2023
a7f34f4
Update task_workers.py
v1r3n Dec 23, 2023
b483300
changes
v1r3n Dec 24, 2023
f3160b6
Update pull_request.yml
v1r3n Dec 24, 2023
82bee14
more changes
v1r3n Dec 24, 2023
f54ab86
Create hello_world.py
v1r3n Dec 25, 2023
447e643
tests
v1r3n Dec 25, 2023
b1d4188
improvements
v1r3n Dec 25, 2023
358dafc
Update orkes_workflow_client.py
v1r3n Dec 25, 2023
56acef3
Update test_workflow_client.py
v1r3n Dec 25, 2023
a4fc29d
Update rest.py
v1r3n Dec 25, 2023
3f4e9cb
test fixes
v1r3n Dec 25, 2023
e6f6923
Update Dockerfile
v1r3n Dec 25, 2023
4c22e7a
Update rest.py
v1r3n Dec 25, 2023
dfc2f71
changes
v1r3n Dec 25, 2023
e3a1f12
Update rest.py
v1r3n Dec 25, 2023
ecb52b3
Update pull_request.yml
v1r3n Dec 25, 2023
63cec4e
Update pull_request.yml
v1r3n Dec 25, 2023
4735c27
Update pull_request.yml
v1r3n Dec 25, 2023
4e52ad0
Update pull_request.yml
v1r3n Dec 25, 2023
c0e7328
Update rest.py
v1r3n Dec 25, 2023
f560c04
Update rest.py
v1r3n Dec 25, 2023
4a32ba5
Update rest.py
v1r3n Dec 25, 2023
e3d755c
Update rest.py
v1r3n Dec 25, 2023
36923e9
Delete test_workflow_apis.py
v1r3n Dec 25, 2023
551b7aa
Update pull_request.yml
v1r3n Dec 25, 2023
b949471
Update pull_request.yml
v1r3n Dec 25, 2023
2e9059f
token refresh
v1r3n Dec 25, 2023
29d8966
more
v1r3n Dec 26, 2023
089c32b
readme
v1r3n Dec 26, 2023
20e9417
updates
v1r3n Dec 26, 2023
12c5485
Update README.md
v1r3n Dec 26, 2023
373f61c
Update README.md
v1r3n Dec 26, 2023
1a2a407
Update README.md
v1r3n Dec 26, 2023
9a7b469
Update README.md
v1r3n Dec 26, 2023
d74e541
Update README.md
v1r3n Dec 26, 2023
c92e62e
more
v1r3n Dec 26, 2023
fc430a1
Update README.md
v1r3n Dec 26, 2023
33ff3be
Update README.md
v1r3n Dec 26, 2023
49082cd
Update README.md
v1r3n Dec 26, 2023
dbebadc
more
v1r3n Dec 26, 2023
d7fca15
Update README.md
v1r3n Dec 26, 2023
432e6ea
changes
v1r3n Dec 26, 2023
53620ca
formatting
v1r3n Dec 26, 2023
daa2482
Update README.md
v1r3n Dec 26, 2023
12de2c6
Update README.md
v1r3n Dec 26, 2023
9e493dc
more
v1r3n Dec 26, 2023
b9468a2
more
v1r3n Dec 26, 2023
2ec554a
Update README.md
v1r3n Dec 26, 2023
0284eb1
Update README.md
v1r3n Dec 26, 2023
2b67fcb
Update README.md
v1r3n Dec 26, 2023
8a71510
Update README.md
v1r3n Dec 26, 2023
c6df900
more changes
v1r3n Dec 27, 2023
5275d66
Update README.md
v1r3n Dec 27, 2023
4009676
more
v1r3n Dec 27, 2023
9670927
Update README.md
v1r3n Dec 27, 2023
64b89d3
more
v1r3n Dec 27, 2023
aeefd02
Update README.md
v1r3n Dec 27, 2023
bcf0faa
test
v1r3n Dec 27, 2023
fc66d74
Update README.md
v1r3n Dec 27, 2023
22c262f
Update README.md
v1r3n Dec 27, 2023
eeb892a
test
v1r3n Dec 27, 2023
a1dcf1f
Update README.md
v1r3n Dec 27, 2023
2da01cd
Update prompt_testing.ipynb
v1r3n Dec 27, 2023
f81b159
clean up
v1r3n Dec 27, 2023
cadd792
tests
v1r3n Dec 27, 2023
81f83e7
fixes
v1r3n Dec 27, 2023
a21ab34
Update workflow_ops.py
v1r3n Dec 27, 2023
1e235c7
Update conductor_workflow.py
v1r3n Dec 27, 2023
f6451d9
more
v1r3n Dec 29, 2023
d158e08
Update test_workflow_client_intg.py
v1r3n Dec 29, 2023
befc5d2
code formatting
v1r3n Dec 29, 2023
c21ec9c
test
v1r3n Dec 29, 2023
495c657
Update test_workflow_client.py
v1r3n Dec 29, 2023
e9475a8
fix error handling
v1r3n Dec 29, 2023
0eb0882
tests
v1r3n Dec 29, 2023
dc65c9f
formatting
v1r3n Dec 29, 2023
8ba12bd
names
v1r3n Dec 29, 2023
9be352a
Update test_orkes_clients.py
v1r3n Dec 29, 2023
360ddf6
Update test_workflow_execution.py
v1r3n Dec 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 59 additions & 32 deletions docs/authorization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,80 @@ authorization_client = OrkesAuthorizationClient(configuration)

#### Creating Application
Creates an application and returns a ConductorApplication object.

```python
from conductor.client.http.models.create_or_update_application_request import CreateOrUpdateApplicationRequest
from conductor.client.http.models.conductor_application import ConductorApplication

request = CreateOrUpdateApplicationRequest("APPLICATION_NAME")
app = authorization_client.createApplication(request)
app = authorization_client.create_application(request)
application_id = app.id
```

#### Get Application

```python
app = authorization_client.getApplication(application_id)
app = authorization_client.get_application(application_id)
```

#### List All Applications

```python
apps = authorization_client.listApplications()
apps = authorization_client.list_applications()
```

#### Update Application
Updates an application and returns a ConductorApplication object.

```python
request = CreateOrUpdateApplicationRequest("APPLICATION_NAME")
updated_app = authorization_client.updateApplication(request, application_id)
updated_app = authorization_client.update_application(request, application_id)
```

#### Delete Application

```python
authorization_client.deleteApplication(application_id)
authorization_client.delete_application(application_id)
```

#### Add a role for an Application user
Add one of the roles out of ["USER", "ADMIN", "METADATA_MANAGER", "WORKFLOW_MANAGER", "USER_READ_ONLY"]
to an application user.

```python
authorization_client.addRoleToApplicationUser(application_id, "USER")
authorization_client.add_role_to_application_user(application_id, "USER")
```

#### Remove a role assigned to an Application user

```python
authorization_client.removeRoleFromApplicationUser(application_id, "USER")
authorization_client.remove_role_from_application_user(application_id, "USER")
```

#### Set Application tags

```python
from conductor.client.orkes.models.metadata_tag import MetadataTag

tags = [
MetadataTag("auth_tag", "val"), MetadataTag("auth_tag_2", "val2")
]
authorization_client.getApplicationTags(tags, application_id)
authorization_client.get_application_tags(tags, application_id)
```

#### Get Application tags

```python
tags = authorization_client.getApplicationTags(application_id)
tags = authorization_client.get_application_tags(application_id)
```

#### Delete Application tags

```python
tags = [
MetadataTag("auth_tag", "val"), MetadataTag("auth_tag_2", "val2")
]
authorization_client.deleteApplicationTags(tags, application_id)
authorization_client.delete_application_tags(tags, application_id)
```

### Access Key Management
Expand All @@ -94,10 +103,11 @@ authorization_client.deleteApplicationTags(tags, application_id)
Creates an access key for the specified application and returns a CreatedAccessKey object.
The SECRET for this access key is available in the returned object. This is the only time
when the secret for this newly created access key can be retrieved and saved.

```python
from conductor.client.orkes.models.created_access_key import CreatedAccessKey

created_access_key = authorization_client.createAccessKey(application_id)
created_access_key = authorization_client.create_access_key(application_id)
```

#### Get Access Key
Expand All @@ -106,24 +116,27 @@ Retrieves all access keys for the specified application as List[AccessKey].
```python
from conductor.client.orkes.models.access_key import AccessKey

access_keys = authorization_client.getAccessKeys(application_id)
access_keys = authorization_client.get_access_keys(application_id)
```

#### Enabling / Disabling Access Key
Toggle access key status between ACTIVE and INACTIVE.

```python
access_key = authorization_client.toggleAccessKeyStatus(application_id, created_access_key.id)
access_key = authorization_client.toggle_access_key_status(application_id, created_access_key.id)
```

#### Delete Acccess Key

```python
authorization_client.deleteAccessKey(application_id, created_access_key.id)
authorization_client.delete_access_key(application_id, created_access_key.id)
```

### User Management

#### Create or Update User
Creates or updates a user and returns a ConductorUser object.

```python
from conductor.client.http.models.upsert_user_request import UpsertUserRequest
from conductor.client.http.models.conductor_user import ConductorUser
Expand All @@ -132,28 +145,32 @@ user_id = 'test.user@company.com'
user_name = "Test User"
roles = ["USER"]
req = UpsertUserRequest(user_name, roles)
user = authorization_client.upsertUser(req, user_id)
user = authorization_client.upsert_user(req, user_id)
```

#### Get User

```python
user = authorization_client.getUser(user_id)
user = authorization_client.get_user(user_id)
```

#### List All Users

```python
users = authorization_client.listUsers()
users = authorization_client.list_users()
```

#### Delete User

```python
authorization_client.deleteUser(user_id)
authorization_client.delete_user(user_id)
```

### Group Management

#### Create or Update a Group
Creates or updates a user group and returns a Group object.

```python
from conductor.client.http.models.upsert_group_request import UpsertGroupRequest
from conductor.client.http.models.group import Group
Expand All @@ -162,45 +179,52 @@ group_id = 'test_group'
group_name = "Test Group"
group_user_roles = ["USER"]
req = UpsertGroupRequest("Integration Test Group", group_user_roles)
group = authorization_client.upsertGroup(req, group_id)
group = authorization_client.upsert_group(req, group_id)
```

#### Get Group

```python
group = authorization_client.getGroup(group_id)
group = authorization_client.get_group(group_id)
```

#### List All Groups
Retrives all groups as a List[Group]

```python
users = authorization_client.listGroups()
users = authorization_client.list_groups()
```

#### Delete Group

```python
authorization_client.deleteGroup(group_id)
authorization_client.delete_group(group_id)
```

#### Add users to a Group

```python
authorization_client.addUserToGroup(group_id, user_id)
authorization_client.add_user_to_group(group_id, user_id)
```

#### Get all users in a Group
Retrives all users in a group as List[ConductorUser]

```python
users = self.authorization_client.getUsersInGroup(group_id)
users = self.authorization_client.get_users_in_group(group_id)
```

#### Remove users from a group

```python
authorization_client.removeUserFromGroup(group_id, user_id)
authorization_client.remove_user_from_group(group_id, user_id)
```

### Permission Management

#### Grant Permissions
Grants a set of accesses to the specified Subject for a given Target.

```python
from conductor.client.http.models.target_ref import TargetRef, TargetType
from conductor.client.http.models.subject_ref import SubjectRef, SubjectType
Expand All @@ -213,34 +237,37 @@ access_group = [AccessType.EXECUTE]
subject_user = SubjectRef(SubjectType.USER, user_id)
access_user = [AccessType.EXECUTE, AccessType.READ]

authorization_client.grantPermissions(subject_group, target, access_group)
authorization_client.grantPermissions(subject_user, target, access_user)
authorization_client.grant_permissions(subject_group, target, access_group)
authorization_client.grant_permissions(subject_user, target, access_user)
```

#### Get Permissions for a Target
Given the target, returns all permissions associated with it as a Dict[str, List[SubjectRef]].
In the returned dictionary, key is AccessType and value is a list of subjects.

```python
from conductor.client.http.models.target_ref import TargetRef, TargetType

target = TargetRef(TargetType.WORKFLOW_DEF, WORKFLOW_NAME)
target_permissions = authorization_client.getPermissions(target)
target_permissions = authorization_client.get_permissions(target)
```

#### Get Permissions granted to a Group
Given a group id, returns all the permissions granted to a group as List[GrantedPermission].

```python
from conductor.client.orkes.models.granted_permission import GrantedPermission

group_permissions = authorization_client.getGrantedPermissionsForGroup(group_id)
group_permissions = authorization_client.get_granted_permissions_for_group(group_id)
```

#### Get Permissions granted to a User
Given a user id, returns all the permissions granted to a user as List[GrantedPermission].

```python
from conductor.client.orkes.models.granted_permission import GrantedPermission

user_permissions = authorization_client.getGrantedPermissionsForUser(user_id)
user_permissions = authorization_client.get_granted_permissions_for_user(user_id)
```

#### Remove Permissions
Expand All @@ -258,6 +285,6 @@ access_group = [AccessType.EXECUTE]
subject_user = SubjectRef(SubjectType.USER, user_id)
access_user = [AccessType.EXECUTE, AccessType.READ]

authorization_client.removePermissions(subject_group, target, access_group)
authorization_client.removePermissions(subject_user, target, access_user)
authorization_client.remove_permissions(subject_group, target, access_group)
authorization_client.remove_permissions(subject_user, target, access_user)
```
4 changes: 2 additions & 2 deletions docs/exceptions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ config = Configuration(server_api_url=SERVER_API_URL, authentication_settings=au
metadata_client = OrkesMetadataClient(config)

try:
metadata_client.getWorkflowDef(WORKFLOW_NAME, 1)
metadata_client.get_workflow_def(WORKFLOW_NAME, 1)
except APIError as e:
if e.code == APIErrorCode.NOT_FOUND:
print(f"Error finding {WORKFLOW_NAME}: {e.message}")
elif e.code == APIErrorCode.FORBIDDEN:
print(f"Error accessing {WORKFLOW_NAME}: {e.message}")
else:
print(f"Error fetching {WORKFLOW_NAME}: {e.message}")

```
18 changes: 9 additions & 9 deletions docs/metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ You should be able to register your workflow at the Conductor Server:
from conductor.client.http.models.workflow_def import WorkflowDef

workflowDef = workflow.to_workflow_def()
metadata_client.registerWorkflowDef(workflowDef, True)
metadata_client.register_workflow_def(workflowDef, True)
```

### Get Workflow Definition

You should be able to get your workflow definiton that you added previously:

```python
wfDef = metadata_client.getWorkflowDef('python_workflow_example_from_code')
wfDef = metadata_client.get_workflow_def('python_workflow_example_from_code')
```

In case there is an error in fetching the definition, errorStr will be populated.
Expand All @@ -80,15 +80,15 @@ You should be able to update your workflow after adding new tasks:
```python
workflow >> SimpleTask("simple_task", "simple_task_ref_2")
updatedWorkflowDef = workflow.to_workflow_def()
metadata_client.updateWorkflowDef(updatedWorkflowDef, True)
metadata_client.update_workflow_def(updatedWorkflowDef, True)
```

### Unregister Workflow Definition

You should be able to unregister your workflow by passing name and version:

```python
metadata_client.unregisterWorkflowDef('python_workflow_example_from_code', 1)
metadata_client.unregister_workflow_def('python_workflow_example_from_code', 1)
```

## Task Definition Management
Expand All @@ -101,19 +101,19 @@ You should be able to register your task at the Conductor Server:
from conductor.client.http.models.task_def import TaskDef

taskDef = TaskDef(
name= "PYTHON_TASK",
name="PYTHON_TASK",
description="Python Task Example",
input_keys=["a", "b"]
)
metadata_client.registerTaskDef(taskDef)
metadata_client.register_task_def(taskDef)
```

### Get Task Definition

You should be able to get your task definiton that you added previously:

```python
taskDef = metadata_client.getTaskDef('PYTHON_TASK')
taskDef = metadata_client.get_task_def('PYTHON_TASK')
```

### Update Task Definition
Expand All @@ -123,15 +123,15 @@ You should be able to update your task definition by modifying field values:
```python
taskDef.description = "Python Task Example New Description"
taskDef.input_keys = ["a", "b", "c"]
metadata_client.updateTaskDef(taskDef)
metadata_client.update_task_def(taskDef)
```

### Unregister Task Definition

You should be able to unregister your task at the Conductor Server:

```python
metadata_client.unregisterTaskDef('python_task_example_from_code')
metadata_client.unregister_task_def('python_task_example_from_code')
```

## Tag Management
Expand Down
Loading