-
Notifications
You must be signed in to change notification settings - Fork 1
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 #53 from seeq12/bugfix/ao/correlation-errors-out-d…
…ue-to-lack-of-crosscorrelation-UDF-CRAB-45677 CRAB 45677: Fix for correlation errors out due to lack of crosscorrelation udf
- Loading branch information
Showing
8 changed files
with
99 additions
and
74 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
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,7 @@ | ||
import textwrap | ||
from seeq import sdk | ||
from seeq import sdk, spy | ||
from seeq.sdk.rest import ApiException | ||
from .utils import check_udf_package, get_user_group, get_user, DEFAULT_USERS, DEFAULT_GROUP | ||
|
||
pearson_formula = textwrap.dedent( | ||
""" | ||
|
@@ -163,16 +164,10 @@ def correlation_udfs(api_client): | |
creator_name = 'Alberto Rivas' | ||
creator_contact_info = '[email protected]' | ||
formulas_api = sdk.FormulasApi(api_client) | ||
try: | ||
pkg = formulas_api.get_package(package_name=package_name) | ||
if pkg.name == package_name: | ||
print(f"Overwriting CrossCorrelation package") | ||
formulas_api.delete_package(package_name=package_name) | ||
except ApiException as e: | ||
if 'not found' in e.reason.lower(): | ||
pass | ||
else: | ||
raise e | ||
found = check_udf_package(package_name, api_client) | ||
if found: | ||
print(f"Overwriting CrossCorrelation package") | ||
formulas_api.delete_package(package_name=package_name) | ||
|
||
# Create the Formula Package | ||
package_input = sdk.FormulaPackageInputV1(creator_name=creator_name, creator_contact_info=creator_contact_info) | ||
|
@@ -290,3 +285,48 @@ def signals_from_formula(signal1_id, signal_ref_id, workbook_id, formula_type=No | |
) | ||
r = signals_api.create_signal_with_http_info(body=payload)[0] | ||
return r | ||
|
||
|
||
def create_udfs(api_client, *, permissions_groups: list = None, permissions_users: list = None): | ||
""" | ||
Creates the required Formula UDFs for the Correlation app | ||
Parameters | ||
---------- | ||
api_client: seeq.sdk.api_client.ApiClient | ||
The seeq.sdk API client that handles the client-server | ||
communication | ||
permissions_groups: list | ||
Names of the Seeq groups that will have access to each tool | ||
permissions_users: list | ||
Names of Seeq users that will have access to each tool | ||
Returns | ||
-------- | ||
-: None | ||
The Correlation UDFs will be available in Seeq Workbench | ||
""" | ||
|
||
permissions_groups = permissions_groups if permissions_groups else DEFAULT_GROUP | ||
permissions_users = permissions_users if permissions_users else DEFAULT_USERS | ||
print("\n\nCreating CrossCorrelation UDFs...") | ||
user_groups_api = sdk.UserGroupsApi(api_client) | ||
users_api = sdk.UsersApi(spy.client) | ||
items_api = sdk.ItemsApi(api_client) | ||
pkg_id = correlation_udfs(api_client) | ||
|
||
# assign group permissions | ||
for group_name in permissions_groups: | ||
group = get_user_group(group_name, user_groups_api) | ||
if group: | ||
ace_input = sdk.AceInputV1(identity_id=group.items[0].id, permissions=sdk.PermissionsV1(read=True)) | ||
items_api.add_access_control_entry(id=pkg_id, body=ace_input) | ||
|
||
# assign user permissions | ||
for user_name in permissions_users: | ||
current_user = get_user(user_name, users_api) | ||
if current_user: | ||
ace_input = sdk.AceInputV1(identity_id=current_user.users[0].id, | ||
permissions=sdk.PermissionsV1(read=True)) | ||
items_api.add_access_control_entry(id=pkg_id, body=ace_input) | ||
|
||
print("DONE") |
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 +1 @@ | ||
__version__ = '0.1.98' | ||
__version__ = '0.1.99' |
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,10 +1,12 @@ | ||
from ._common import validate_argument_types, print_red, path_list_to_string, path_string_to_list | ||
from ._cache_management import clear_cache_all | ||
from ._permissions import get_user, get_user_group | ||
from ._sdl import pull_only_signals, get_worksheet_url, get_workbook_worksheet_workstep_ids, get_seeq_url | ||
from ._permissions import get_user, get_user_group, DEFAULT_USERS, DEFAULT_GROUP | ||
from ._sdl import (pull_only_signals, get_worksheet_url, get_workbook_worksheet_workstep_ids, get_seeq_url, | ||
check_udf_package) | ||
from ._seeq_new_content import create_condition, create_workstep_signals | ||
|
||
|
||
__all__ = ['validate_argument_types', 'print_red', 'create_condition', 'create_workstep_signals', 'get_user', | ||
'get_user_group', 'pull_only_signals', 'get_worksheet_url', 'get_workbook_worksheet_workstep_ids', | ||
'clear_cache_all', 'get_seeq_url', 'path_list_to_string', 'path_string_to_list'] | ||
'clear_cache_all', 'get_seeq_url', 'path_list_to_string', 'path_string_to_list', 'check_udf_package', | ||
'DEFAULT_USERS', 'DEFAULT_GROUP'] |
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