Skip to content

Commit

Permalink
updated account name specification (#171)
Browse files Browse the repository at this point in the history
Co-authored-by: pyansys-ci-bot <[email protected]>
  • Loading branch information
philipjusher and pyansys-ci-bot authored Jan 23, 2025
1 parent 55c8fe2 commit e474d3c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/171.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
updated account name specification
8 changes: 1 addition & 7 deletions examples/simple_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@

# Set the path to the configuration file
SETTINGS_FILE = Path().cwd().parents[2] / "tests" / "config.toml"
print(SETTINGS_FILE)
print(SETTINGS_FILE.exists())
os.environ["PYCONCEPTEV_SETTINGS"] = str(SETTINGS_FILE)


import plotly.graph_objects as go

from ansys.conceptev.core import app, auth
Expand Down Expand Up @@ -110,11 +107,8 @@
health = app.get(client, "/health")
print(f"API is healthy: {health}\n")

accounts = app.get_account_ids(token)
# Uncomment to print accounts IDs
# print(f"Account IDs: {accounts}\n")
account_id = app.get_account_id(token)

account_id = accounts["ConceptEv Test Account"]
hpc_id = app.get_default_hpc(token, account_id)
product_id = app.get_product_id(token)
# Uncomment to print HPC ID
Expand Down
8 changes: 8 additions & 0 deletions src/ansys/conceptev/core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
JOB_TIMEOUT = settings.job_timeout
OCM_URL = settings.ocm_url
BASE_URL = settings.conceptev_url
ACCOUNT_NAME = settings.account_name
app = auth.create_msal_app()


Expand Down Expand Up @@ -282,6 +283,13 @@ def get_account_ids(token: str) -> dict:
return accounts


def get_account_id(token: str) -> str:
"""Get the account ID from OCM using name from config file."""
accounts = get_account_ids(token)
account_id = accounts[ACCOUNT_NAME]
return account_id


def get_default_hpc(token: str, account_id: str) -> dict:
"""Get the default HPC ID."""
response = httpx.post(
Expand Down
1 change: 1 addition & 0 deletions src/ansys/conceptev/core/resources/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ client_id = 'd8434bbf-552c-4672-ac1b-1cadbef28144'
authority = 'https://ansysaccount.b2clogin.com/ansysaccount.onmicrosoft.com/B2C_1A_ANSYSID_SIGNUP_SIGNIN'
scope ='https://ansysaccount.onmicrosoft.com/AnsysID/Authentication'
conceptev_username = "[email protected]"
account_name = "[email protected]"
job_timeout= 3600
ENVIRONMENT = "production"
1 change: 1 addition & 0 deletions src/ansys/conceptev/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Settings(BaseSettings):
environment: Environment
conceptev_username: EmailStr | None # Only works in testing environment
conceptev_password: str | None # Only works in testing environment
account_name: str | None
model_config = SettingsConfigDict(
env_file=[TOML_FILE, "./config.toml"], secrets_dir=RESOURCE_DIRECTORY
)
Expand Down
1 change: 1 addition & 0 deletions tests/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ client_id = "9c9edb71-06f9-4c4b-afed-9201668385de"
authority = "https://a365dev.b2clogin.com/a365dev.onmicrosoft.com/b2c_1a_ansysid_signup_signin_test"
scope = "https://a365dev.onmicrosoft.com/AnsysID/Authentication"
CONCEPTEV_USERNAME = "[email protected]"
account_name = "ConceptEv Test Account"
JOB_TIMEOUT = 3600
ENVIRONMENT = "testing"

0 comments on commit e474d3c

Please sign in to comment.