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

add missing dependencies for serverless, disable docs-style #147

Merged
merged 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 10 additions & 11 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ env:

jobs:
style:

name: Code style
runs-on: ubuntu-latest
steps:
Expand All @@ -36,14 +35,14 @@ jobs:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
show-diff-on-failure: false

docs-style:
name: Documentation style check
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: ansys/actions/doc-style@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
# docs-style:
# name: Documentation style check
# runs-on: ubuntu-latest
# steps:
# - name: PyAnsys documentation style checks
# uses: ansys/actions/doc-style@v4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}

smoke-tests:
name: Build and smoke tests
Expand Down Expand Up @@ -115,7 +114,7 @@ jobs:
docs:
name: Build docs
runs-on: ubuntu-latest
needs: [docs-style]
# needs: [docs-style]
steps:
- name: Run Ansys documentation building action
uses: ansys/actions/doc-build@v4
Expand Down Expand Up @@ -184,7 +183,7 @@ jobs:
build-failure:
name: Teams notify on failure
if: failure() && (github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.ref_type == 'tag')
needs: [ style, test, docs-style ]
needs: [ style, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
20 changes: 13 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,25 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"build>=0.8.0",
"django~=4.2",
"djangorestframework~=3.14",
"filelock>=3.7.1",
"numpy>=1.18.0,<2",
"packaging>=21.0",
"docker>=7.1.0",
"pypng>=0.20220715.0",
"python-dateutil>=2.8.0",
"pytz>=2021.3",
"requests>=2.32",
"urllib3<3.0.0",
"Pillow>=9.3.0",
"python-dateutil>=2.8.0",
"pytz>=2021.3",
"packaging>=21.0",
"build>=0.8.0",
# core ADR dependencies
"django~=4.2",
"djangorestframework~=3.14",
"django-guardian~=2.4",
"tzlocal~=5.0",
"numpy>=1.18.0,<2",
"python-pptx==0.6.19",
"pandas~=2.0",
"statsmodels~=0.14",
]

[tool.setuptools.packages.find]
Expand Down
35 changes: 19 additions & 16 deletions src/ansys/dynamicreporting/core/serverless/adr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Iterable
# from collections.abc import Iterable
import os
from pathlib import Path
import platform
Expand All @@ -8,7 +8,8 @@

import django
from django.core import management
from django.db import IntegrityError, connection, connections

# from django.db import IntegrityError, connection, connections
from django.http import HttpRequest

from .. import DEFAULT_ANSYS_VERSION
Expand All @@ -31,14 +32,14 @@ def __init__(
self,
ansys_installation: str,
*,
db_directory: str = None,
databases: dict = None,
media_directory: str = None,
static_directory: str = None,
debug: bool = None,
opts: dict = None,
request: HttpRequest = None,
logfile: str = None,
db_directory: Optional[str] = None,
databases: Optional[dict] = None,
media_directory: Optional[str] = None,
static_directory: Optional[str] = None,
debug: Optional[bool] = None,
opts: Optional[dict] = None,
request: Optional[HttpRequest] = None,
logfile: Optional[str] = None,
) -> None:
self._db_directory = None
self._databases = databases or {}
Expand Down Expand Up @@ -87,7 +88,7 @@ def __init__(
elif "CEI_NEXUS_LOCAL_STATIC_DIR" in os.environ:
self._static_directory = self._check_dir(os.environ["CEI_NEXUS_LOCAL_STATIC_DIR"])

def _get_install_directory(self, ansys_installation: Optional[str]) -> Path:
def _get_install_directory(self, ansys_installation: str) -> Path:
dirs_to_check = []
if ansys_installation:
# User passed directory
Expand Down Expand Up @@ -151,7 +152,7 @@ def setup(self, collect_static: bool = False) -> None:
if self._databases:
if "default" not in self._databases:
raise ImproperlyConfiguredError(
""" The database configuration must be a dictionary of the following format with
""" The 'databases' option must be a dictionary of the following format with
a "default" database specified.
{
"default": {
Expand Down Expand Up @@ -273,7 +274,9 @@ def get_report(self, **kwargs) -> Template:
self._logger.error(f"{e}")
raise e

def get_reports(self, fields: list = None, flat: bool = False) -> Union[ObjectSet, list]:
def get_reports(
self, fields: Optional[list] = None, flat: bool = False
) -> Union[ObjectSet, list]:
# return list of reports by default.
# if fields are mentioned, return value list
try:
Expand All @@ -286,7 +289,7 @@ def get_reports(self, fields: list = None, flat: bool = False) -> Union[ObjectSe

return out

def get_list_reports(self, r_type: Optional[str] = "name") -> Union[ObjectSet, list]:
def get_list_reports(self, r_type: str = "name") -> Union[ObjectSet, list]:
supported_types = ["name", "report"]
if r_type not in supported_types:
raise ADRException(f"r_type must be one of {supported_types}")
Expand All @@ -295,7 +298,7 @@ def get_list_reports(self, r_type: Optional[str] = "name") -> Union[ObjectSet, l
else:
return self.get_reports()

def render_report(self, context: dict = None, query: str = None, **kwargs: Any) -> str:
def render_report(self, context: Optional[dict] = None, query: str = "", **kwargs: Any) -> str:
try:
return Template.get(**kwargs).render(
request=self._request, context=context, query=query
Expand All @@ -307,7 +310,7 @@ def render_report(self, context: dict = None, query: str = None, **kwargs: Any)
def query(
self,
query_type: Union[Session, Dataset, Type[Item], Type[Template]],
query: Optional[str] = "",
query: str = "",
) -> ObjectSet:
if not issubclass(query_type, (Item, Template, Session, Dataset)):
self._logger.error(f"{query_type} is not valid")
Expand Down
2 changes: 2 additions & 0 deletions src/ansys/dynamicreporting/core/serverless/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def from_db(cls, orm_instance, parent=None):

@handle_field_errors
def save(self, **kwargs):
self._saved = False # reset

cls_fields = self._get_all_field_names()
model_fields = self._get_orm_field_names(self._orm_instance)
for field_ in cls_fields:
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dynamicreporting/core/serverless/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def find(cls, **kwargs):
new_kwargs = {**kwargs, "query": f"A|t_types|cont|{cls.report_type};{query}"}
return super().find(**new_kwargs)

def render(self, context=None, request=None, query=None) -> Optional[str]:
def render(self, context=None, request=None, query="") -> str:
if context is None:
context = {}
ctx = {**context, "request": request, "ansys_version": None}
Expand Down
Loading