Skip to content

Commit

Permalink
edit toml file with automatic update
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvlaminck committed Jun 21, 2024
1 parent 9bd0052 commit c058866
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion model_update/ModelUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update_model(cls, version_info_file_path: Path, otl_version: str, created_by

current_model_version = version_info['current']['model_version']
model_version = cls.update_model_version(updated_class_model=updated_class_model, updated_enums=updated_enums,
model_version=current_model_version, otl_version=otl_version)
model_version=current_model_version, otl_version=otl_version)

if current_model_version == model_version:
raise ValueError(f'The model version you are trying to update to is the same as the current version: '
Expand Down
20 changes: 19 additions & 1 deletion model_update/automatic_update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import logging
import toml
import urllib.request
from pathlib import Path
from subprocess import Popen, PIPE
Expand Down Expand Up @@ -36,6 +38,22 @@
ModelUpdater.update_model(version_info_file_path=version_info_file_path, otl_version=version,
created_by='automatic_update.py', enums_updated=enums_updated)

cmd = "git add ./../otlmow_model"
with open(version_info_file_path, encoding='utf-8') as file:
version_info = json.load(file)

current_model_version = version_info['current']['model_version']

data = toml.load(current_dir.parent / 'pyproject.toml')

data['project']['version'] = current_model_version

with open(current_dir.parent / 'pyproject.toml', 'w') as f:
toml.dump(data, f)

cmd = 'git add ./../otlmow_model'
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = p.communicate()

cmd = 'git add ./pyproject.toml'
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = p.communicate()
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ pytest>=6.2.5
pytest-cov>=4.0.0
pytest-subtests>=0.8.0
pytest-timeout>=1.4.2
otlmow_model~=2.10.4.0
otlmow_modelbuilder~=0.14

11 changes: 11 additions & 0 deletions requirements_update.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
attrs>=22.2.0
coverage>=3.7.1
iniconfig>=1.1.1
packaging>=21.0
pluggy>=1.0.0
pytest>=6.2.5
pytest-cov>=4.0.0
pytest-subtests>=0.8.0
pytest-timeout>=1.4.2
otlmow_modelbuilder~=0.14
toml~=0.10.2

0 comments on commit c058866

Please sign in to comment.