Skip to content

Commit

Permalink
Merge pull request #1861 from OpenEnergyPlatform/release-v1.0.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
jh-RLI authored Sep 22, 2024
2 parents 1247cde + 210e58f commit 1a71ad8
Show file tree
Hide file tree
Showing 93 changed files with 6,279 additions and 2,340 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.21.5
current_version = 1.0.0

[bumpversion:file:VERSION]

Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/automated-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ jobs:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- name: Install linux dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y postgresql-client
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
Expand All @@ -76,11 +76,11 @@ jobs:
sleep 2
done
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -90,19 +90,22 @@ jobs:
run: |
python -m pip install --upgrade pip 'setuptools<72.0.0' wheel
pip install -r requirements.txt
pip install tox
pip install tox-uv
- name: Add schemas for testing
env:
PGPASSWORD: postgres
run: |
psql -h localhost -p 5432 -U postgres -c "CREATE SCHEMA IF NOT EXISTS sandbox" oedb
psql -h localhost -p 5432 -U postgres -c "CREATE SCHEMA IF NOT EXISTS _sandbox" oedb
- name: OEO-Integration & Test data
- name: oeo & oeo-ext integration
run: |
mkdir -p ontologies/oeo/1/
mkdir -p ontologies/oeo/1/imports
mkdir -p ontologies/oeo/1/modules
wget https://openenergy-platform.org/ontology/oeo/releases/oeo-full.owl -P ontologies/oeo/1/
wget https://openenergyplatform.org/ontology/oeo/releases/oeo-full.owl -P ontologies/oeo/1/
mkdir -p media/oeo_ext/
cp oeo_ext/oeo_extended_store/oeox_template/oeo_ext_template_empty.owl media/oeo_ext/oeo_ext.owl
- name: Collectstatic files & compress
run: |
cp oeplatform/securitysettings.py.default oeplatform/securitysettings.py
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
key: ${{ github.ref }}
path: .cache
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ authors:
title: "Open Energy Family - Open Energy Platform (OEP)"
type: software
license: AGPL-3.0-or-later
version: 0.21.5
version: 1.0.0
doi:
date-released: 2024-08-19
date-released: 2024-09-23
url: "https://github.com/OpenEnergyPlatform/oeplatform/"
2 changes: 1 addition & 1 deletion RELEASE_PROCEDURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Before see How to [Contribute](https://github.com/OpenEnergyPlatform/oeplatform/
![git branching model](https://nvie.com/img/[email protected])

1. Merge all feature and hotfix branches into `develop`
1. Starting out in the `develop` branch, make a release candidate branch (e.g., `release/vx.x.x`)
1. Starting out in the `develop` branch, make a release candidate branch (e.g., `release-vx.x.x`)
1. Update the oeplatform/versions/changelogs/ [`current.md`](https://github.com/OpenEnergyPlatform/oeplatform/blob/develop/versions/changelogs/current.md) (see the examples of previous releases)
- Change filename to release version (x_x_x.md)
- Copy template to `current.md`
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.21.5
1.0.0
61 changes: 47 additions & 14 deletions api/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
from dataedit.models import Table as DBTable
from dataedit.structures import TableTags as OEDBTableTags
from dataedit.structures import Tag as OEDBTag
from oeplatform.securitysettings import PLAYGROUNDS, UNVERSIONED_SCHEMAS
from login.utils import validate_open_data_license
from oeplatform.settings import PLAYGROUNDS, UNVERSIONED_SCHEMAS

pgsql_qualifier = re.compile(r"^[\w\d_\.]+$")

Expand Down Expand Up @@ -830,7 +831,7 @@ def assert_valid_identifier_name(identifier):
"Table names must consist of lowercase alpha-numeric words or underscores "
"and start with a letter "
f"and must not exceed {MAX_IDENTIFIER_LENGTH} characters "
"(current table name length: {len(identifier)})."
f"(current table name length: {len(identifier)})."
)


Expand Down Expand Up @@ -1555,7 +1556,7 @@ def move(from_schema, table, to_schema):
except DBTable.DoesNotExist:
raise APIError("Table for schema movement not found")
try:
to_schema_reg = DBSchema.objects.get(name=to_schema)
to_schema_reg, _ = DBSchema.objects.get_or_create(name=to_schema)
except DBSchema.DoesNotExist:
raise APIError("Target schema not found")
if from_schema == to_schema:
Expand Down Expand Up @@ -1609,21 +1610,46 @@ def move(from_schema, table, to_schema):

def move_publish(from_schema, table_name, to_schema, embargo_period):
"""
The issue about publishing datatables in the context of the OEP
is that tables must be moved physically in the postgreSQL database.
We need to move the table in the OEDB to update the data & we need
to update the table registry in the OEP django database to keep the
display information up to date.
This function tackales this issue. It implements a procedure in witch
the order of execturion matter as for example before updating the
schema / datatopic it shall be published in we need to check if the
table is already in that schema & if the table holds and open data
license in its metadata.
Implementation note:
Currently we implemented two versions of the move functionality
this will later be harmonized. See 'move'.
Args:
Returns:
"""
engine = _get_engine()
Session = sessionmaker(engine)
session = Session()

try:
t = DBTable.objects.get(name=table_name, schema__name=from_schema)
to_schema_reg = DBSchema.objects.get(name=to_schema)
to_schema_reg, _ = DBSchema.objects.get_or_create(name=to_schema)

if from_schema == to_schema:
raise APIError("Target schema same as current schema")

license_check, license_error = validate_open_data_license(t)

if not license_check and to_schema != "model_draft":
raise APIError(
"A issue with the license from the metadata was found: "
f"{license_error}"
)

t.schema = to_schema_reg

meta_to_schema = get_meta_schema_name(to_schema)
Expand Down Expand Up @@ -1659,6 +1685,7 @@ def move_publish(from_schema, table_name, to_schema, embargo_period):
OEDBTableTags.schema_name == from_schema,
OEDBTableTags.table_name == table_name,
).update({OEDBTableTags.schema_name: to_schema})

if embargo_period in ["6_months", "1_year"]:
duration_in_weeks = 26 if embargo_period == "6_months" else 52
embargo, created = Embargo.objects.get_or_create(
Expand All @@ -1668,17 +1695,23 @@ def move_publish(from_schema, table_name, to_schema, embargo_period):
"date_ended": datetime.now() + timedelta(weeks=duration_in_weeks),
},
)
if not created and embargo.date_started is not None:
embargo.date_ended = embargo.date_started + timedelta(
weeks=duration_in_weeks
)
embargo.save()
elif not created:
embargo.date_started = datetime.now()
embargo.date_ended = embargo.date_started + timedelta(
weeks=duration_in_weeks
)
if not created:
if embargo.date_started:
embargo.duration = embargo_period
embargo.date_ended = embargo.date_started + timedelta(
weeks=duration_in_weeks
)
else:
embargo.duration = embargo_period
embargo.date_started = datetime.now()
embargo.date_ended = embargo.date_started + timedelta(
weeks=duration_in_weeks
)
embargo.save()
elif embargo_period == "none":
if Embargo.objects.filter(table=t).exists():
reset_embargo = Embargo.objects.get(table=t)
reset_embargo.delete()

all_peer_reviews = PeerReview.objects.filter(table=t, schema=from_schema)

Expand Down
12 changes: 6 additions & 6 deletions api/helpers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@


class ModHttpResponse(HttpResponse):
def __init__(self, dictonary):
if dictonary is None:
def __init__(self, dictionary):
if dictionary is None:
HttpResponse.__init__(self, status=500)
return

if dictonary["success"]:
if dictionary["success"]:
HttpResponse.__init__(self, status=200)
return

# TODO: Find smarter way to just define a parameter, if an expression is true.
if dictonary["error"] is not None:
if dictionary["error"] is not None:
HttpResponse.__init__(
self, status=dictonary["http_status"], reason=dictonary["error"]
self, status=dictionary["http_status"], reason=dictionary["error"]
)
return
else:
HttpResponse.__init__(self, status=dictonary["http_status"])
HttpResponse.__init__(self, status=dictionary["http_status"])
return
33 changes: 21 additions & 12 deletions api/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def assertDictEqualKeywise(self, d1, d2, excluded=None):

def api_req(
self,
method,
table=None,
schema=None,
path=None,
data=None,
method: str,
table: str = None,
schema: str = None,
path: str = None,
data: dict = None,
auth=None,
exp_code=None,
exp_code: int = None,
exp_res=None,
):
path = path or ""
Expand Down Expand Up @@ -116,7 +116,14 @@ def api_req(
exp_code = 201
else:
exp_code = 200
self.assertEqualJson(resp.status_code, exp_code, msg=json_resp)

if not isinstance(exp_code, (list, tuple)):
exp_code = [exp_code]

self.assertTrue(
resp.status_code in exp_code,
f"Status {resp.status_code} not in {exp_code}: {json_resp}",
)

if exp_res:
if json_resp and "data" in json_resp:
Expand All @@ -125,7 +132,9 @@ def api_req(

return json_resp

def create_table(self, structure=None, data=None, schema=None, table=None):
def create_table(
self, structure=None, data=None, schema=None, table=None, exp_code=201
):
# default structure
structure = structure or {"columns": [{"name": "id", "data_type": "bigint"}]}
self.api_req("put", table, schema, data={"query": structure})
Expand All @@ -136,11 +145,11 @@ def create_table(self, structure=None, data=None, schema=None, table=None):
schema,
"rows/new",
data={"query": data},
exp_code=201,
exp_code=exp_code,
)

def drop_table(self, schema=None, table=None):
self.api_req("delete", table, schema)
def drop_table(self, schema=None, table=None, exp_code=200):
self.api_req("delete", table, schema, exp_code=exp_code)


class APITestCaseWithTable(APITestCase):
Expand Down Expand Up @@ -183,5 +192,5 @@ def setUp(self) -> None:
self.create_table(structure=self.test_structure, data=self.test_data)

def tearDown(self) -> None:
super().setUp()
super().tearDown()
self.drop_table()
Loading

0 comments on commit 1a71ad8

Please sign in to comment.