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

drop official 3.9 support and add 3.13 support #490

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

env:
DOCUMENTATION_CNAME: 'ensight.docs.pyansys.com'
MAIN_PYTHON_VERSION: '3.10'
MAIN_PYTHON_VERSION: '3.13'
PACKAGE_NAME: 'ansys-pyensight-core'
PACKAGE_NAMESPACE: 'ansys.pyensight.core'
ENSIGHT_IMAGE: 'ghcr.io/ansys-internal/ensight_dev'
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12', '3.13']
should-release:
- ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
exclude:
Expand All @@ -71,7 +71,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

env:
MAIN_PYTHON_VERSION: '3.10'
MAIN_PYTHON_VERSION: '3.13'
PACKAGE_NAME: 'ansys-pyensight-core'
ENSIGHT_IMAGE: 'ghcr.io/ansys-internal/ensight_dev'

Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0 # IF VERSION CHANGES --> MODIFY "blacken-docs" MANUALLY AS WELL!!
rev: 24.10.0 # IF VERSION CHANGES --> MODIFY "blacken-docs" MANUALLY AS WELL!!
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies: ["tomli"]
args: ["--ignore-words", "doc/styles/config/vocabularies/ANSYS/accept.txt"]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.8.0
hooks:
- id: bandit
# args not working with pyproject.toml
Expand All @@ -34,15 +34,15 @@ repos:
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.13.0
hooks:
- id: mypy
# Exclude only works here, not in config files
exclude: "tests/|doc/|src/ansys/pyensight/core/exts/|exts/"


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: debug-statements
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and
expression, level of experience, education, socio-economic status, nationality,
expression, level of experience, education, socioeconomic status, nationality,
personal appearance, race, religion, or sexual identity and orientation.

## Our Standards
Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx documentation configuration file."""

from datetime import datetime
import json
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

"""


###############################################################################
# Start an EnSight session
# ------------------------
Expand Down
4 changes: 2 additions & 2 deletions doc/source/examples_source/50-advanced/01-remote_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def myfunc(ensight):

start = time.time()
names = myfunc(session.ensight)
print(f"Remote: {time.time()-start}")
print(f"Remote: {time.time() - start}")
print(names)

cmd = "def myfunc():\n"
Expand All @@ -130,7 +130,7 @@ def myfunc(ensight):
session.cmd(cmd, do_eval=False)
start = time.time()
names = session.cmd("myfunc()")
print(f"Remote: {time.time()-start}")
print(f"Remote: {time.time() - start}")
print(names)


Expand Down
1 change: 1 addition & 0 deletions doc/styles/config/vocabularies/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ SOSConstant
Stimpson
subpackage
te
THIRDPARTY
timestep1
timestep2
Tij
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ classifiers = [
"Topic :: Scientific/Engineering :: Information Analysis",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

dependencies = [
Expand Down Expand Up @@ -160,7 +160,7 @@ recursive = true
exclude = ["venv/*", "tests/*"]

[tool.mypy]
python_version = 3.9
python_version = "3.10"
strict = false
namespace_packages = true
explicit_package_bases = true
Expand Down
22 changes: 16 additions & 6 deletions src/ansys/pyensight/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def find_unused_ports(count: int, avoid: Optional[List[int]] = None) -> Optional
return ports # pragma: no cover


def get_host_port(uri: str) -> Tuple[str, int]:
def get_host_port(uri: str) -> Optional[Tuple[str, int]]:
"""Get the host port for the input uri

Parameters
Expand All @@ -98,7 +98,9 @@ def get_host_port(uri: str) -> Tuple[str, int]:
if parse_results.port
else (443 if re.search("^https|wss$", parse_results.scheme) else None)
)
return (parse_results.host, port)
if port:
return (parse_results.host, port)
return None


def get_file_service(pim_instance: Any) -> Optional[Any]: # pragma: no cover
Expand Down Expand Up @@ -155,12 +157,20 @@ def populate_service_host_port( # pragma: no cover
"If channel is specified, the PIM instance must have a list of length 3 "
+ "containing the appropriate service URIs. It does not."
)
service_host_port["grpc_private"] = get_host_port(pim_instance.services["grpc_private"].uri)
service_host_port["http"] = get_host_port(pim_instance.services["http"].uri)
service_host_port["ws"] = get_host_port(pim_instance.services["ws"].uri)
grpc_private = get_host_port(pim_instance.services["grpc_private"].uri)
http = get_host_port(pim_instance.services["http"].uri)
ws = get_host_port(pim_instance.services["ws"].uri)
if grpc_private:
service_host_port["grpc_private"] = grpc_private
if http:
service_host_port["http"] = http
if ws:
service_host_port["ws"] = ws
service_host_port["grpc"] = ("127.0.0.1", -1)
if webui:
service_host_port["webui"] = get_host_port(pim_instance.services["webui"].uri)
webui_vals = get_host_port(pim_instance.services["webui"].uri)
if webui_vals:
service_host_port["webui"] = webui_vals
return service_host_port


Expand Down
1 change: 1 addition & 0 deletions src/ansys/pyensight/core/dockerlauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
session.close()

"""

import logging
import os.path
import subprocess
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/pyensight/core/enscontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#. Simple context: an EnSight context file without any data loading reference.

"""

import base64
import io
import os
Expand Down Expand Up @@ -93,7 +94,7 @@ def _from_data(self, data: Union[bytes, str]) -> None:
context zip file.

"""
if type(data) != bytes:
if not isinstance(data, bytes):
data = base64.b64decode(data)
self._buffer = io.BytesIO(data)
the_file = zipfile.ZipFile(self._buffer, "r")
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/pyensight/core/enshell_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
This class provides an asynchronous interface to the EnShell
core gRPC interface.
"""

import logging
import os
import random
Expand Down Expand Up @@ -244,7 +245,7 @@ def metadata(self): # pragma: no cover
ret = list()
if self._security_token is not None:
s = self._security_token
if type(s) == str:
if isinstance(s, str):
s = s.encode("utf-8")
ret.append((b"shared_secret", s))
return ret
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/pyensight/core/ensight_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
interface to the EnSight gRPC interface, including event streams.

"""

from concurrent import futures
import os
import platform
Expand Down Expand Up @@ -192,7 +193,7 @@ def _metadata(self) -> List[Tuple[bytes, Union[str, bytes]]]:
s: Union[str, bytes]
if self._security_token: # pragma: no cover
s = self._security_token
if type(s) == str: # pragma: no cover
if isinstance(s, str): # pragma: no cover
s = s.encode("utf-8")
ret.append((b"shared_secret", s))
if self.session_name: # pragma: no cover
Expand Down
1 change: 1 addition & 0 deletions src/ansys/pyensight/core/ensobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The ensobj module provides the base class to all EnSight proxy objects

"""

from typing import TYPE_CHECKING, Any, Optional, no_type_check

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions src/ansys/pyensight/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class implement specific launching paradigms.
session = LocalLauncher().start()

"""

import os.path
import platform
import re
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/pyensight/core/libuserd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
>>> userd.shutdown()

"""

import enum
import logging
import os
Expand Down Expand Up @@ -1424,7 +1425,7 @@ def metadata(self) -> List[Tuple[bytes, Union[str, bytes]]]:
s: Union[str, bytes]
if self._security_token: # pragma: no cover
s = self._security_token
if type(s) == str: # pragma: no cover
if isinstance(s, str): # pragma: no cover
s = s.encode("utf-8")
ret.append((b"shared_secret", s))
return ret
Expand Down
7 changes: 3 additions & 4 deletions src/ansys/pyensight/core/listobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Emulation of the EnSight ensobjlist class

"""

from collections.abc import Iterable
import fnmatch
from typing import (
Expand Down Expand Up @@ -217,12 +218,10 @@ def get_attr(self, attr: Any, default: Optional[Any] = None):
return [default] * len(objid_list) # pragma: no cover

@overload
def __getitem__(self, index: SupportsIndex) -> T:
...
def __getitem__(self, index: SupportsIndex) -> T: ... # noqa: E704

@overload
def __getitem__(self, index: slice) -> List[T]:
...
def __getitem__(self, index: slice) -> List[T]: ... # noqa: E704

def __getitem__(self, index):
"""Overload the getitem operator to allow for tuple and string DESCRIPTION queries"""
Expand Down
1 change: 1 addition & 0 deletions src/ansys/pyensight/core/locallauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
>>> from ansys.pyensight.core import LocalLauncher
>>> session = LocalLauncher().start()
"""

import glob
import logging
import os.path
Expand Down
1 change: 1 addition & 0 deletions src/ansys/pyensight/core/renderable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This module provides the interface for creating objects in the EnSight session
that can be displayed via HTML over the websocket server interface.
"""

import hashlib
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions src/ansys/pyensight/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ansys.pyensight.Session

"""

import atexit
import importlib.util
from os import listdir
Expand Down
18 changes: 9 additions & 9 deletions src/ansys/pyensight/core/utils/dsg_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def update_geom(self, cmd: dynamic_scene_graph_pb2.UpdateGeom) -> None:
elif cmd.payload_type == dynamic_scene_graph_pb2.UpdateGeom.LINES:
if self.conn_lines.size != cmd.total_array_size:
self.conn_lines = numpy.resize(self.conn_lines, cmd.total_array_size)
self.conn_lines[
cmd.chunk_offset : cmd.chunk_offset + len(cmd.int_array)
] = cmd.int_array
self.conn_lines[cmd.chunk_offset : cmd.chunk_offset + len(cmd.int_array)] = (
cmd.int_array
)
elif (cmd.payload_type == dynamic_scene_graph_pb2.UpdateGeom.ELEM_NORMALS) or (
cmd.payload_type == dynamic_scene_graph_pb2.UpdateGeom.NODE_NORMALS
):
Expand All @@ -168,9 +168,9 @@ def update_geom(self, cmd: dynamic_scene_graph_pb2.UpdateGeom) -> None:
)
if self.tcoords.size != cmd.total_array_size:
self.tcoords = numpy.resize(self.tcoords, cmd.total_array_size)
self.tcoords[
cmd.chunk_offset : cmd.chunk_offset + len(cmd.flt_array)
] = cmd.flt_array
self.tcoords[cmd.chunk_offset : cmd.chunk_offset + len(cmd.flt_array)] = (
cmd.flt_array
)

# Add the variable hash to the Part's hash, to pick up palette changes
var_cmd = self.session.variables.get(cmd.variable_id, None)
Expand All @@ -181,9 +181,9 @@ def update_geom(self, cmd: dynamic_scene_graph_pb2.UpdateGeom) -> None:
# Receive the node size var values
if self.node_sizes.size != cmd.total_array_size:
self.node_sizes = numpy.resize(self.node_sizes, cmd.total_array_size)
self.node_sizes[
cmd.chunk_offset : cmd.chunk_offset + len(cmd.flt_array)
] = cmd.flt_array
self.node_sizes[cmd.chunk_offset : cmd.chunk_offset + len(cmd.flt_array)] = (
cmd.flt_array
)
# Combine the hashes for the UpdatePart and all UpdateGeom messages
self.hash.update(cmd.hash.encode("utf-8"))

Expand Down
3 changes: 2 additions & 1 deletion src/ansys/pyensight/core/utils/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
>>> parts.select_by_dimension(3)

"""

from types import ModuleType
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union

Expand Down Expand Up @@ -317,7 +318,7 @@ def _create_emitters(
)
else:
new_emitters.append(
f"ensight.utils.parts._EnSEmitterPart(ensight, part={convert_part(self.ensight ,p)}, num_points={num_points}, part_kind={part_distribution_type})"
f"ensight.utils.parts._EnSEmitterPart(ensight, part={convert_part(self.ensight , p)}, num_points={num_points}, part_kind={part_distribution_type})"
)
else:
raise RuntimeError(
Expand Down
Loading
Loading