-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from specklesystems/gergo/automation_runner_r…
…efactor gergo/automation runner refactor
- Loading branch information
Showing
10 changed files
with
283 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "specklepy" | ||
version = "2.9.1" | ||
version = "2.17.5" | ||
description = "The Python SDK for Speckle 2.0" | ||
readme = "README.md" | ||
authors = ["Speckle Systems <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""Some useful helpers for working with automation data.""" | ||
import secrets | ||
import string | ||
|
||
from specklepy.api.client import SpeckleClient | ||
from gql import gql | ||
|
||
|
||
def register_new_automation( | ||
speckle_client: SpeckleClient, | ||
project_id: str, | ||
model_id: str, | ||
automation_id: str, | ||
automation_name: str, | ||
automation_revision_id: str, | ||
) -> bool: | ||
"""Register a new automation in the speckle server.""" | ||
query = gql( | ||
""" | ||
mutation CreateAutomation( | ||
$projectId: String! | ||
$modelId: String! | ||
$automationName: String! | ||
$automationId: String! | ||
$automationRevisionId: String! | ||
) { | ||
automationMutations { | ||
create( | ||
input: { | ||
projectId: $projectId | ||
modelId: $modelId | ||
automationName: $automationName | ||
automationId: $automationId | ||
automationRevisionId: $automationRevisionId | ||
} | ||
) | ||
} | ||
} | ||
""" | ||
) | ||
params = { | ||
"projectId": project_id, | ||
"modelId": model_id, | ||
"automationName": automation_name, | ||
"automationId": automation_id, | ||
"automationRevisionId": automation_revision_id, | ||
} | ||
return speckle_client.httpclient.execute(query, params) | ||
|
||
|
||
def crypto_random_string(length: int) -> str: | ||
"""Generate a semi crypto random string of a given length.""" | ||
alphabet = string.ascii_letters + string.digits | ||
return "".join(secrets.choice(alphabet) for _ in range(length)).lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.