Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Utilities
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Denis Tombrink
Utilities
Commits
ec2020b7
Commit
ec2020b7
authored
10 months ago
by
Duc Bui Tien
Browse files
Options
Downloads
Patches
Plain Diff
add modules conf save and load
parent
31f98303
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.idea/workspace.xml
+27
-9
27 additions, 9 deletions
.idea/workspace.xml
main.py
+25
-4
25 additions, 4 deletions
main.py
test_main.http
+1
-1
1 addition, 1 deletion
test_main.http
xmlConfigReader.py
+12
-0
12 additions, 0 deletions
xmlConfigReader.py
with
65 additions
and
14 deletions
.idea/workspace.xml
+
27
−
9
View file @
ec2020b7
...
...
@@ -4,7 +4,7 @@
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"ade4f2dd-968a-4099-9236-831254f6eb55"
name=
"Changes"
comment=
"
add get_modulePath
"
>
<list
default=
"true"
id=
"ade4f2dd-968a-4099-9236-831254f6eb55"
name=
"Changes"
comment=
"
refactor convergence endpoints update modules endpoints
"
>
<change
afterPath=
"$PROJECT_DIR$/xmlConfigReader.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/main.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/main.py"
afterDir=
"false"
/>
...
...
@@ -76,8 +76,8 @@
<recent
name=
"C:\Users\d_bui\PycharmProjects\fastApiUnicado"
/>
</key>
</component>
<component
name=
"RunManager"
selected=
"
Python.xmlConfigReader
"
>
<configuration
name=
"test_main | #
5
"
type=
"HttpClient.HttpRequestRunConfigurationType"
factoryName=
"HTTP Request"
temporary=
"true"
nameIsGenerated=
"true"
path=
"$PROJECT_DIR$/test_main.http"
index=
"
5
"
requestIdentifier=
"#
5
"
runType=
"Run single request"
>
<component
name=
"RunManager"
selected=
"
FastAPI.fastApiUnicado
"
>
<configuration
name=
"test_main | #
4
"
type=
"HttpClient.HttpRequestRunConfigurationType"
factoryName=
"HTTP Request"
temporary=
"true"
nameIsGenerated=
"true"
path=
"$PROJECT_DIR$/test_main.http"
index=
"
4
"
requestIdentifier=
"#
4
"
runType=
"Run single request"
>
<method
v=
"2"
/>
</configuration>
<configuration
name=
"test_main | #6"
type=
"HttpClient.HttpRequestRunConfigurationType"
factoryName=
"HTTP Request"
temporary=
"true"
nameIsGenerated=
"true"
path=
"$PROJECT_DIR$/test_main.http"
index=
"6"
requestIdentifier=
"#6"
runType=
"Run single request"
>
...
...
@@ -149,11 +149,11 @@
</configuration>
<recent_temporary>
<list>
<item
itemvalue=
"HTTP Request.test_main | #4"
/>
<item
itemvalue=
"Python.xmlConfigReader"
/>
<item
itemvalue=
"Python.test"
/>
<item
itemvalue=
"HTTP Request.test_main | #8"
/>
<item
itemvalue=
"HTTP Request.test_main | #6"
/>
<item
itemvalue=
"HTTP Request.test_main | #5"
/>
</list>
</recent_temporary>
</component>
...
...
@@ -233,7 +233,16 @@
<workItem
from=
"1719577095693"
duration=
"43000"
/>
<workItem
from=
"1719577148084"
duration=
"603000"
/>
<workItem
from=
"1719995851952"
duration=
"466000"
/>
<workItem
from=
"1719996576928"
duration=
"3299000"
/>
<workItem
from=
"1719996576928"
duration=
"7097000"
/>
<workItem
from=
"1720075595422"
duration=
"8540000"
/>
<workItem
from=
"1720173999845"
duration=
"3367000"
/>
<workItem
from=
"1720591643068"
duration=
"596000"
/>
<workItem
from=
"1720594508888"
duration=
"4366000"
/>
<workItem
from=
"1720765983827"
duration=
"2471000"
/>
<workItem
from=
"1721116263498"
duration=
"2729000"
/>
<workItem
from=
"1721286344593"
duration=
"5576000"
/>
<workItem
from=
"1721769527434"
duration=
"238000"
/>
<workItem
from=
"1721974616129"
duration=
"2742000"
/>
</task>
<task
id=
"LOCAL-00001"
summary=
"add update_Modules"
>
<option
name=
"closed"
value=
"true"
/>
...
...
@@ -259,7 +268,15 @@
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1710427169439
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"4"
/>
<task
id=
"LOCAL-00004"
summary=
"refactor convergence endpoints update modules endpoints"
>
<option
name=
"closed"
value=
"true"
/>
<created>
1720008890021
</created>
<option
name=
"number"
value=
"00004"
/>
<option
name=
"presentableId"
value=
"LOCAL-00004"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1720008890021
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"5"
/>
<servers
/>
</component>
<component
name=
"TypeScriptGeneratedFilesManager"
>
...
...
@@ -292,11 +309,12 @@
<MESSAGE
value=
"add update_Modules"
/>
<MESSAGE
value=
"prototyp config, graph und log endpoints"
/>
<MESSAGE
value=
"add get_modulePath"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"add get_modulePath"
/>
<MESSAGE
value=
"refactor convergence endpoints update modules endpoints"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"refactor convergence endpoints update modules endpoints"
/>
</component>
<component
name=
"com.intellij.coverage.CoverageDataManagerImpl"
>
<SUITE
FILE_PATH=
"coverage/fastApiUnicado$test.coverage"
NAME=
"test Coverage Results"
MODIFIED=
"1711008069985"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"true"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$"
/>
<SUITE
FILE_PATH=
"coverage/fastApiUnicado$xmlConfigReader.coverage"
NAME=
"xmlConfigReader Coverage Results"
MODIFIED=
"17200
07025187
"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"false"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$"
/>
<SUITE
FILE_PATH=
"coverage/fastApiUnicado$fastApiUnicado.coverage"
NAME=
"fastApiUnicado Coverage Results"
MODIFIED=
"1719
3843630
03"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"false"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
""
/>
<SUITE
FILE_PATH=
"coverage/fastApiUnicado$xmlConfigReader.coverage"
NAME=
"xmlConfigReader Coverage Results"
MODIFIED=
"17200
78308255
"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"false"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$"
/>
<SUITE
FILE_PATH=
"coverage/fastApiUnicado$fastApiUnicado.coverage"
NAME=
"fastApiUnicado Coverage Results"
MODIFIED=
"17
2
19
77726
03
4
"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"false"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
""
/>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.py
+
25
−
4
View file @
ec2020b7
import
json
from
fastapi
import
FastAPI
from
fastapi.responses
import
FileResponse
import
os
...
...
@@ -6,6 +8,7 @@ from subprocess import Popen, PIPE
from
fastapi.middleware.cors
import
CORSMiddleware
from
pydantic
import
BaseModel
import
xmltodict
from
fastapi.encoders
import
jsonable_encoder
app
=
FastAPI
()
...
...
@@ -31,6 +34,10 @@ class Convergence(BaseModel):
class
Modules
(
BaseModel
):
groups
:
list
=
[]
class
Conf
(
BaseModel
):
name
:
str
;
controll_settings
:
dict
=
{}
def
search_modules
(
dict
,
name
,
root
):
list
=
[]
for
i
in
range
(
len
(
root
.
findall
(
f
"
ProgramSettings/
{
name
}
/Program/Name
"
))):
...
...
@@ -55,7 +62,7 @@ async def start_module(module: str):
@app.get
(
"
/convergence
"
)
async
def
get_modules
():
async
def
get_
conv_
modules
():
tree
=
ET
.
parse
(
'
newProject/convergenceLoop/convergenceLoop_conf.xml
'
)
root
=
tree
.
getroot
()
dict
=
{}
...
...
@@ -66,6 +73,13 @@ async def get_modules():
tree
.
write
(
"
test.xml
"
)
return
dict
@app.get
(
"
/modules
"
)
async
def
get_modules
():
with
open
(
"
test
"
,
"
r
"
)
as
fp
:
modules
=
json
.
load
(
fp
)
return
modules
@app.put
(
"
/convergence/update
"
)
async
def
update_convergence
(
item
:
Convergence
):
...
...
@@ -81,7 +95,10 @@ async def update_convergence(item: Convergence):
@app.put
(
"
/modules/update
"
)
async
def
update_modules
(
item
:
Modules
):
print
(
item
)
print
(
jsonable_encoder
(
item
))
with
open
(
"
test
"
,
"
w
"
)
as
fp
:
json
.
dump
(
jsonable_encoder
(
item
),
fp
)
return
item
...
...
@@ -94,9 +111,13 @@ async def get_module_config(module: str):
@app.get
(
"
/modules/{module}/config
"
)
async
def
get_module_config
(
module
:
str
):
tree
=
ET
.
parse
(
"
xml_configs/
"
+
module
+
"
_conf
ig
.xml
"
)
tree
=
ET
.
parse
(
"
xml_configs/
"
+
module
+
"
_conf.xml
"
)
root
=
tree
.
getroot
()
config
=
xmltodict
.
XmlDictConfig
(
root
)
config
=
json
.
dumps
(
xmltodict
.
XmlDictConfig
(
root
))
return
config
@app.put
(
"
/modules/config/update
"
)
async
def
update_module_config
(
config
:
Conf
):
print
(
config
)
return
config
@app.get
(
"
/graph/
"
)
...
...
This diff is collapsed.
Click to expand it.
test_main.http
+
1
−
1
View file @
ec2020b7
...
...
@@ -15,7 +15,7 @@ Accept: application/json
###
GET http://127.0.0.1:8000/modules/
test
/config
GET http://127.0.0.1:8000/modules/
initialSizing
/config
Accept: application/json
###
...
...
This diff is collapsed.
Click to expand it.
xmlConfigReader.py
0 → 100644
+
12
−
0
View file @
ec2020b7
from
pydantic
import
BaseModel
import
xmltodict
import
os
import
xml.etree.ElementTree
as
ET
import
json
tree
=
ET
.
parse
(
"
xml_configs/initialSizing_conf.xml
"
)
root
=
tree
.
getroot
()
config
=
xmltodict
.
XmlDictConfig
(
root
)
print
(
config
)
print
(
json
.
dumps
(
config
,
sort_keys
=
True
,
indent
=
4
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment