Skip to content

Commit

Permalink
v2.17.3
Browse files Browse the repository at this point in the history
Merge pull request #2096 from AntaresSimulatorTeam/release/v2.17.3
  • Loading branch information
skamril committed Jul 18, 2024
2 parents 23027df + 80b9b39 commit 4150708
Show file tree
Hide file tree
Showing 113 changed files with 8,860 additions and 1,676 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/compatibility.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: choco install wget --no-progress

- name: 💚 Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.16.1

Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
strategy:
max-parallel: 9
matrix:
os: [ windows-latest, ubuntu-20.04 ]
os: [windows-latest, ubuntu-20.04]

steps:
- name: Checkout github repo (+ download lfs dependencies)
Expand Down Expand Up @@ -69,12 +69,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04 ]
os: [ubuntu-20.04]
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.16.1
- name: Install dependencies
Expand All @@ -89,10 +89,13 @@ jobs:
- name: Lint
run: npm run lint
working-directory: webapp
- name: Test
run: npm run test
working-directory: webapp

sonarcloud:
runs-on: ubuntu-20.04
needs: [ python-test, npm-test ]
needs: [python-test, npm-test]
steps:
- uses: actions/checkout@v4
- name: Download python coverage report
Expand Down
4 changes: 2 additions & 2 deletions antarest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

# Standard project metadata

__version__ = "2.17.2"
__version__ = "2.17.3"
__author__ = "RTE, Antares Web Team"
__date__ = "2024-06-19"
__date__ = "2024-07-18"
# noinspection SpellCheckingInspection
__credits__ = "(c) Réseau de Transport de l’Électricité (RTE)"

Expand Down
29 changes: 29 additions & 0 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,35 @@ def __init__(self, is_variant: bool) -> None:
super().__init__(HTTPStatus.EXPECTATION_FAILED, "Upgrade not supported for parent of variants")


class ReferencedObjectDeletionNotAllowed(HTTPException):
"""
Exception raised when a binding constraint is not allowed to be deleted because it references
other objects: areas, links or thermal clusters.
"""

def __init__(self, object_id: str, binding_ids: t.Sequence[str], *, object_type: str) -> None:
"""
Initialize the exception.
Args:
object_id: ID of the object that is not allowed to be deleted.
binding_ids: Binding constraints IDs that reference the object.
object_type: Type of the object that is not allowed to be deleted: area, link or thermal cluster.
"""
max_count = 10
first_bcs_ids = ",\n".join(f"{i}- '{bc}'" for i, bc in enumerate(binding_ids[:max_count], 1))
and_more = f",\nand {len(binding_ids) - max_count} more..." if len(binding_ids) > max_count else "."
message = (
f"{object_type} '{object_id}' is not allowed to be deleted, because it is referenced"
f" in the following binding constraints:\n{first_bcs_ids}{and_more}"
)
super().__init__(HTTPStatus.FORBIDDEN, message)

def __str__(self) -> str:
"""Return a string representation of the exception."""
return self.detail


class UnsupportedStudyVersion(HTTPException):
def __init__(self, version: str) -> None:
super().__init__(
Expand Down
13 changes: 6 additions & 7 deletions antarest/study/business/binding_constraint_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,12 @@ def terms_to_coeffs(terms: t.Sequence[ConstraintTerm]) -> t.Dict[str, t.List[flo
:return: A dictionary of term IDs mapped to a list of their coefficients.
"""
coeffs = {}
if terms is not None:
for term in terms:
if term.id and term.weight is not None:
coeffs[term.id] = [term.weight]
if term.offset:
coeffs[term.id].append(term.offset)
return coeffs
for term in terms:
if term.id and term.weight is not None:
coeffs[term.id] = [term.weight]
if term.offset:
coeffs[term.id].append(term.offset)
return coeffs

def get_binding_constraint(self, study: Study, bc_id: str) -> ConstraintOutput:
"""
Expand Down
38 changes: 31 additions & 7 deletions antarest/study/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,37 @@ class ExportFormat(str, enum.Enum):
TAR_GZ = "application/tar+gz"
JSON = "application/json"

@staticmethod
def from_dto(data: str) -> "ExportFormat":
if data == "application/zip":
return ExportFormat.ZIP
if data == "application/tar+gz":
return ExportFormat.TAR_GZ
return ExportFormat.JSON
@classmethod
def from_dto(cls, accept_header: str) -> "ExportFormat":
"""
Convert the "Accept" header to the corresponding content type.
Args:
accept_header: Value of the "Accept" header.
Returns:
The corresponding content type: ZIP, TAR_GZ or JSON.
By default, JSON is returned if the format is not recognized.
For instance, if the "Accept" header is "*/*", JSON is returned.
"""
mapping = {
"application/zip": ExportFormat.ZIP,
"application/tar+gz": ExportFormat.TAR_GZ,
"application/json": ExportFormat.JSON,
}
return mapping.get(accept_header, ExportFormat.JSON)

@property
def suffix(self) -> str:
"""
Returns the file suffix associated with the format: ".zip", ".tar.gz" or ".json".
"""
mapping = {
ExportFormat.ZIP: ".zip",
ExportFormat.TAR_GZ: ".tar.gz",
ExportFormat.JSON: ".json",
}
return mapping[self]


class StudyDownloadDTO(BaseModel):
Expand Down
Loading

0 comments on commit 4150708

Please sign in to comment.