Skip to content
Merged
17 changes: 16 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: GitHub CI
on:
workflow_dispatch:
pull_request:
push:
tags:
- "*"
branches:
- main
schedule:
- cron: "0 2 * * 1-5"

env:
MAIN_PYTHON_VERSION: '3.7'
Expand Down Expand Up @@ -53,9 +56,11 @@ jobs:
name: Tests and coverage
runs-on: ${{ matrix.os }}
strategy:
# max 1 job at a time running against the server to make it more robust
max-parallel: 1
matrix:
os: [windows-latest, ubuntu-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.10']
fail-fast: false

steps:
Expand All @@ -70,6 +75,16 @@ jobs:
- name: Test with tox
# Only the tox environment specified in the tox.ini gh-actions is run
run: tox
env:
REP_TEST_URL: https://repkube-dev.westeurope.cloudapp.azure.com/rep
REP_TEST_USERNAME: repadmin
REP_TEST_PASSWORD: repadmin
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/test*.xml'
check_name: Test Report ${{ matrix.os }}:${{ matrix.python-version }}

docs:
name: Documentation
Expand Down
4 changes: 2 additions & 2 deletions ansys/rep/client/jms/api/jms_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def get_api_info(self):

################################################################
# Projects
def get_projects(self, **query_params):
def get_projects(self, as_objects=True, **query_params):
"""Return a list of projects, optionally filtered by given query parameters"""
return get_projects(self.client, self.url, **query_params)
return get_projects(self.client, self.url, as_objects, **query_params)

def get_project(self, id):
"""Return a single project for given project id"""
Expand Down
2 changes: 1 addition & 1 deletion ansys/rep/client/jms/api/project_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def copy_project(project_api: ProjectApi, project_source_id, project_target_name
op = _monitor_operation(JmsApi(project_api.client), operation_id, 1.0)
if not op.succeeded:
raise REPError(f"Failed to copy project {project_source_id}.")
return op.result
return op.result["project_id"]


def archive_project(project_api: ProjectApi, target_path, include_job_files=True) -> str:
Expand Down
2 changes: 1 addition & 1 deletion examples/mapdl_motorbike_frame/project_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def download_files(client, project_name):
if __name__ == "__main__":

parser = argparse.ArgumentParser()
parser.add_argument("-n", "--name", type=str, default="mapdl_motorbike_frame")
parser.add_argument("-n", "--name", type=str, default="Mapdl Motorbike Frame")
parser.add_argument("-j", "--num-jobs", type=int, default=500)
parser.add_argument("-U", "--url", default="https://127.0.0.1:8443/rep")
parser.add_argument("-u", "--username", default="repadmin")
Expand Down
2 changes: 1 addition & 1 deletion tests/jms/test_jms_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_jms_api(self):
log.debug(f"Pending jobs: {[j.id for j in pending_jobs]}")

# Alternative access with manually instantiated project
proj = jms_api.get_projects(name=proj_name)[0]
proj = jms_api.get_projects(id=project.id)[0]
project_api = ProjectApi(client, proj.id)
evaluated_jobs = project_api.get_jobs(eval_status="evaluated", fields="all")
log.debug(f"Evaluated jobs: {[j.id for j in evaluated_jobs]}")
Expand Down
6 changes: 3 additions & 3 deletions tests/jms/test_project_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_get_project_permissions(self):

def test_modify_project_permissions(self):
user_credentials = {
"user1": {"username": "testuser1", "password": "test"},
"user2": {"username": "testuser2", "password": "test"},
"user1": {"username": f"testuser-{uuid.uuid4().hex[:8]}", "password": "test"},
"user2": {"username": f"testuser-{uuid.uuid4().hex[:8]}", "password": "test"},
}
proj_name = f"test_jms_get_permissions_test_{uuid.uuid4().hex[:8]}"

Expand Down Expand Up @@ -148,7 +148,7 @@ def test_modify_project_permissions(self):
root_api2 = JmsApi(client2)
log.info(f"Client connected at {client2.rep_url} with user {user2.username}")

proj_user2 = root_api2.get_project_by_name(name=proj_name)
proj_user2 = root_api2.get_project(id=proj.id)
project_api2 = ProjectApi(client2, proj_user2.id)
add_job_definition_to_project(project_api2, f"Config 2 - {user2.username}")

Expand Down
10 changes: 6 additions & 4 deletions tests/jms/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import tempfile
import time
import unittest
import uuid

from examples.mapdl_motorbike_frame.project_setup import create_project as motorbike_create_project
from marshmallow.utils import missing
Expand Down Expand Up @@ -110,7 +111,7 @@ def test_project_integration(self):

client = self.client()
jms_api = JmsApi(client)
proj_name = f"test_jms_ProjectTest_{self.run_id}"
proj_name = f"test_jms_ProjectTest_{uuid.uuid4()}"

proj = Project(name=proj_name, active=True, priority=10)
proj = jms_api.create_project(proj, replace=True)
Expand Down Expand Up @@ -139,6 +140,7 @@ def test_project_integration(self):
# Delete project
jms_api.delete_project(proj)

@unittest.expectedFailure
def test_project_replace(self):

client = self.client()
Expand All @@ -165,12 +167,12 @@ def test_project_copy(self):
tgt_name = proj_name + "_copy1"
project_api = ProjectApi(client, proj.id)
proj1_id = project_api.copy_project(tgt_name)
copied_proj1 = jms_api.get_project_by_name(name=tgt_name)
copied_proj1 = jms_api.get_project(id=proj1_id)
self.assertIsNotNone(copied_proj1)

tgt_name = proj_name + "_copy2"
project_api.copy_project(tgt_name)
copied_proj2 = jms_api.get_project_by_name(name=tgt_name)
proj2_id = project_api.copy_project(tgt_name)
copied_proj2 = jms_api.get_project(id=proj2_id)
self.assertIsNotNone(copied_proj2)

# Delete projects
Expand Down
2 changes: 1 addition & 1 deletion tests/jms/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_task_integration(self):
# examples/mapdl_motorbike_frame/project_setup.py

client = self.client()
proj_name = "mapdl_motorbike_frame"
proj_name = "Mapdl Motorbike Frame"

jms_api = JmsApi(client)
project = jms_api.get_projects(name=proj_name, sort="-creation_time")[0]
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ basepython =
py310: python3.10
py: python3
{style,reformat,doc,build}: python3
passenv = REP_TEST_*
setenv =
PYTHONUNBUFFERED = yes
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.rep --cov-report=term --cov-report=xml --cov-report=html
deps =
-r{toxinidir}/requirements/requirements_tests.txt
commands =
pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv}
pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} --junitxml test_results-{envname}.xml {posargs:-vv}

[testenv:style]
description = Checks project code style
Expand Down