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

Feature/improved automated testing #168

Merged
merged 34 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2fc8036
updated to use test account
philipjusher Jan 16, 2025
64c5725
updated to use test account
philipjusher Jan 16, 2025
761f16d
update to use secrets
philipjusher Jan 16, 2025
befcf5d
Merge remote-tracking branch 'origin/feature/improved_automated_testi…
philipjusher Jan 16, 2025
85652b9
update settings
philipjusher Jan 17, 2025
2a1ee32
update test check for testing environment
philipjusher Jan 20, 2025
35eb83a
chore: adding changelog file 168.added.md [dependabot-skip]
pyansys-ci-bot Jan 20, 2025
d3efda5
updating license headers
philipjusher Jan 20, 2025
54b0316
Merge remote-tracking branch 'origin/feature/improved_automated_testi…
philipjusher Jan 20, 2025
f5a1b69
temporary flag to stop being blocked by licences
philipjusher Jan 20, 2025
4104884
whitelist licence validator and remove unnessary env variables
philipjusher Jan 20, 2025
13b2bd3
sorting out path variables for doc test
philipjusher Jan 20, 2025
b2ad0ec
update config toml for examples
philipjusher Jan 20, 2025
d24b78a
file test
philipjusher Jan 20, 2025
1f69f08
added some missing dependencies
philipjusher Jan 20, 2025
2f38e8d
added some missing dependencies
philipjusher Jan 20, 2025
f9d96d0
added some missing dependencies
philipjusher Jan 20, 2025
4885765
added some missing dependencies
philipjusher Jan 20, 2025
11604ef
add pygobject for linux
philipjusher Jan 21, 2025
4a5d3c5
update ci/cd
philipjusher Jan 21, 2025
b5c11e8
just adding dependencies till it works
philipjusher Jan 21, 2025
74ea5d4
trying without pyproject dependency
philipjusher Jan 21, 2025
ce40a9b
followed the docs fingers crossed
philipjusher Jan 21, 2025
e57886b
moved doc dependencies
philipjusher Jan 21, 2025
bb73e95
try windows to build docs
philipjusher Jan 21, 2025
51d23af
updating back to following instructions
philipjusher Jan 22, 2025
b27aec8
some changes
philipjusher Jan 22, 2025
5228f23
update to match github actions for the library
philipjusher Jan 22, 2025
30a09ad
removed the wrong py dependency
philipjusher Jan 22, 2025
1287621
trying to fall back to not use encryption on linux since the dependen…
philipjusher Jan 22, 2025
444fa66
mimic install commands betweeen the tests and docs
philipjusher Jan 22, 2025
afe990b
exactly the same
philipjusher Jan 22, 2025
5a91fe6
updated if statement
philipjusher Jan 22, 2025
894a648
added dependency to linux
philipjusher Jan 22, 2025
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
24 changes: 20 additions & 4 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,20 @@ jobs:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Install dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install gobject-introspection
sudo apt update
sudo apt install python3-dev libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 gnome-keyring
- name: Build wheelhouse and perform smoke test
uses: ansys/actions/build-wheelhouse@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
operating-system: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
whitelist-license-check: email_validator
RobKellyAnsys marked this conversation as resolved.
Show resolved Hide resolved

tests:
name: Tests and coverage
Expand All @@ -101,12 +109,18 @@ jobs:
python-version: ["3.9","3.10","3.11"]
fail-fast: false
steps:
- name: Install dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y pandoc
sudo apt-get install texlive-latex-extra texlive-xetex texlive-fonts-extra
sudo apt-get install gobject-introspection
sudo apt update
sudo apt install python3-dev libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 gnome-keyring
- uses: ansys/actions/tests-pytest@v8
env:
CONCEPTEV_PASSWORD: ${{ secrets.CONCEPTEV_PASSWORD }}
CONCEPTEV_URL: ${{ vars.CONCEPTEV_URL }}
CONCEPTEV_USERNAME: ${{ vars.CONCEPTEV_USERNAME }}
OCM_URL: ${{ vars.OCM_URL }}
POETRY_VIRTUALENVS_CREATE: ${{ vars.POETRY_VIRTUALENVS_CREATE }}
with:
pytest-extra-args: "-m 'not integration' --cov=ansys --cov-report=term --cov-report=html:.cov/html"
Expand Down Expand Up @@ -137,14 +151,16 @@ jobs:
sudo apt-get update
sudo apt-get install -y pandoc
sudo apt-get install texlive-latex-extra texlive-xetex texlive-fonts-extra
sudo apt-get install gobject-introspection
sudo apt update
sudo apt install python3-dev libgirepository1.0-dev libcairo2-dev gir1.2-secret-1 gnome-keyring
# sudo apt-get install libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf texlive-xetex xindy

- name: Verify Pandoc installation
run: pandoc --version

- name: Build documentation
env:
CONCEPTEV_USERNAME: ${{ secrets.CONCEPTEV_USERNAME }}
CONCEPTEV_PASSWORD: ${{ secrets.CONCEPTEV_PASSWORD }}
uses: ansys/actions/doc-build@v8
with:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
Copyright (c) 2023 - 2025 ANSYS, Inc. and/or its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/168.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature/improved automated testing
70 changes: 27 additions & 43 deletions examples/simple_workflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
Expand All @@ -24,36 +24,29 @@
#
# This example shows how to use PyConcentEV to perform basic operations.

import datetime

# ## Perform required imports
#
# Perform required imports.

import datetime
import os
from pathlib import Path

import plotly.graph_objects as go

from ansys.conceptev.core import app, auth
# 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)

# ## Set up environment variables
# AnsysID is the only supported method.
# We only use the other one here for automated testing. So set to True.
use_ansys_id = False # True

import plotly.graph_objects as go

if not (use_ansys_id):
# Set environment variables for ConceptEV username and password if they don't exist!
if os.environ.get("CONCEPTEV_USERNAME") is None:
os.environ["CONCEPTEV_USERNAME"] = "joe.blogs@my_work.com"
if os.environ.get("CONCEPTEV_PASSWORD") is None:
os.environ["CONCEPTEV_PASSWORD"] = "sup3r_s3cr3t_passw0rd"
from ansys.conceptev.core import app, auth

# ## Define example data
#
# You can obtain example data from the schema sections of the API documentation.

# +
MOTOR_LAB_FILE = Path("resources") / "e9.lab"
MOTOR_LOSS_MAP_FILE = Path("resources") / "e9.xlsx"
AERO_1 = {
Expand Down Expand Up @@ -106,13 +99,10 @@

motor_data = {"name": "e9", "component_type": "MotorLabID", "inverter_losses_included": False}

if use_ansys_id:
# Get a token from Ansys ID (Preferred)
msal_app = auth.create_msal_app()
token = auth.get_ansyId_token(msal_app)
else:
# Get a token from OCM (Deprecated)
token = app.get_token()

# Get a token from Ansys ID
msal_app = auth.create_msal_app()
token = auth.get_ansyId_token(msal_app)


# Use API client for the Ansys ConceptEV service
Expand All @@ -124,7 +114,7 @@
# Uncomment to print accounts IDs
# print(f"Account IDs: {accounts}\n")

account_id = accounts["[email protected]"]
account_id = accounts["ConceptEv Test Account"]
hpc_id = app.get_default_hpc(token, account_id)
RobKellyAnsys marked this conversation as resolved.
Show resolved Hide resolved
product_id = app.get_product_id(token)
# Uncomment to print HPC ID
Expand Down Expand Up @@ -237,22 +227,16 @@
}
created_requirement = app.post(client, "requirements", data=requirement)
print(f"Created requirement: {created_requirement}")
# -


# Following code is not working in the pipelne but should work in a local environment.

# Submit a job and show the result.
# with app.get_http_client(token, design_instance_id) as client:
#
# # Create and submit a job
# concept = app.get(client, "/concepts", id=design_instance_id, params={"populated": True})
# job_info = app.create_submit_job(client, concept, account_id, hpc_id)
#
# # Read the results and show the result in your browser
# results = app.read_results(client, job_info, calculate_units=False, filtered=True)
# x = results[0]["capability_curve"]["speeds"]
# y = results[0]["capability_curve"]["torques"]
#
# fig = go.Figure(data=go.Scatter(x=x, y=y))
# fig.show()
# Create and submit a job
concept = app.get(client, "/concepts", id=design_instance_id, params={"populated": True})
job_info = app.create_submit_job(client, concept, account_id, hpc_id)

# Doesn't work in test environment but should work for users.
# # Read the results and show the result in your browser
# results = app.read_results(client, job_info, calculate_units=False, filtered=True)
# x = results[0]["capability_curve"]["speeds"]
# y = results[0]["capability_curve"]["torques"]
#
# fig = go.Figure(data=go.Scatter(x=x, y=y))
# fig.show()
Loading
Loading