Skip to content

Commit c84d356

Browse files
committed
fixing the dependency installing issue
1 parent 94f5660 commit c84d356

File tree

3 files changed

+117
-45
lines changed

3 files changed

+117
-45
lines changed

.github/workflows/rpe_test.yml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
matrix:
2020
os:
2121
- ubuntu-latest
22-
- ubuntu-22.04 # This is CentOS 7 under the hood
22+
- ubuntu-22.04
2323
- macos-12
2424
- windows-latest
2525
runs-on: ${{ matrix.os }}
@@ -33,13 +33,12 @@ jobs:
3333
if: ${{ matrix.os != 'ubuntu-22.04' }}
3434
uses: actions/setup-node@v4
3535
with:
36-
node-version: 20.11 #if update this then also update in Dockerfile for centos
36+
node-version: 20.11
3737

3838
- name: Setup Python
39-
if: ${{ matrix.os != 'ubuntu-22.04' }}
40-
uses: actions/[email protected]
39+
uses: actions/setup-python@v5
4140
with:
42-
python-version: 3.8 #if update this then also update in Dockerfile for centos
41+
python-version: 3.8
4342

4443
- name: Login to the Container registry
4544
if: ${{ matrix.os == 'ubuntu-22.04' }}
@@ -59,13 +58,13 @@ jobs:
5958
node --version
6059
python3 -V
6160
62-
- name: Shell configuration on centos 7
61+
- name: Shell configuration on CentOS 7
6362
if: ${{ matrix.os == 'ubuntu-22.04' }}
6463
uses: addnab/docker-run-action@v3
6564
with:
6665
shell: bash
6766
image: ghcr.io/${{ github.repository_owner }}/rapid_power_estimator:centos7latest
68-
run:
67+
run: |
6968
source /opt/rh/devtoolset-11/enable
7069
cmake --version
7170
node --version
@@ -82,7 +81,7 @@ jobs:
8281
run: |
8382
npx eslint src/
8483
85-
- name: Install packages centos 7 & Run pytest & frontend test
84+
- name: Install packages CentOS 7 & Run pytest & frontend test
8685
if: ${{ matrix.os == 'ubuntu-22.04' }}
8786
uses: addnab/docker-run-action@v3
8887
with:
@@ -111,7 +110,7 @@ jobs:
111110
fail-fast: false
112111
matrix:
113112
os:
114-
- ubuntu-22.04 # This is CentOS 7 under the hood
113+
- ubuntu-22.04
115114
- macos-12
116115
- windows-latest
117116
runs-on: ${{ matrix.os }}
@@ -128,13 +127,12 @@ jobs:
128127
if: ${{ matrix.os != 'ubuntu-22.04' }}
129128
uses: actions/setup-node@v4
130129
with:
131-
node-version: 20.11 #if update this then also update in Dockerfile for centos
130+
node-version: 20.11
132131

133132
- name: Setup Python
134-
if: ${{ matrix.os != 'ubuntu-22.04' }}
135-
uses: actions/[email protected]
133+
uses: actions/setup-python@v5
136134
with:
137-
python-version: 3.8 #if update this then also update in Dockerfile for centos
135+
python-version: 3.8
138136

139137
- name: Login to the Container registry
140138
if: ${{ matrix.os == 'ubuntu-22.04' }}
@@ -154,7 +152,7 @@ jobs:
154152
node --version
155153
python3 -V
156154
157-
- name: Shell configuration on centos 7
155+
- name: Shell configuration on CentOS 7
158156
if: ${{ matrix.os == 'ubuntu-22.04' }}
159157
uses: addnab/docker-run-action@v3
160158
with:
@@ -215,14 +213,12 @@ jobs:
215213
name: rapid_power_estimator_${{ matrix.os }}
216214
path: dist/rapid_power_estimator*.exe
217215

218-
219216
- name: Upload Release
220217
if: ${{ matrix.os != 'windows-latest' && contains(github.ref, 'refs/tags/') }}
221218
uses: softprops/action-gh-release@v1
222219
with:
223220
files: dist/rapid_power_estimator*.tar.gz
224221

225-
226222
- name: Upload Release
227223
if: ${{ matrix.os == 'windows-latest' && contains(github.ref, 'refs/tags/') }}
228224
uses: softprops/action-gh-release@v1
@@ -239,14 +235,24 @@ jobs:
239235

240236
- name: Set up Python
241237
uses: actions/setup-python@v5
238+
with:
239+
python-version: 3.8
240+
241+
- name: Set up virtual environment
242+
run: |
243+
python3 -m venv venv
244+
source venv/bin/activate
242245
243-
- name: Install dependencies
244-
run: |
245-
pip install -r requirements.txt
246-
npm install
246+
- name: Install dependencies in virtual environment
247+
run: |
248+
source venv/bin/activate
249+
pip install -r requirements.txt
250+
npm install
247251
248252
- name: Run pytest with Codecov
249-
run: python3 -m pytest --cov=. --cov-report=term-missing
253+
run: |
254+
source venv/bin/activate
255+
python3 -m pytest --cov=. --cov-report=term-missing
250256
251257
- name: Upload results to Codecov
252258
uses: codecov/codecov-action@v4
@@ -261,4 +267,4 @@ jobs:
261267
uses: codecov/codecov-action@v4
262268
with:
263269
token: ${{ secrets.CODECOV_TOKEN }}
264-
slug: os-fpga/rapid_power_estimator
270+
slug: os-fpga/rapid_power_estimator

src/components/Tables/ACPUTable.js

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ function ACPUTable({ device, update, notify }) {
3333
const [disable, setDisable] = React.useState(true);
3434
const loadActivity = GetOptions('A45_Load');
3535

36+
// Toggle handler to enable/disable ACPU fields
37+
const handleToggle = () => {
38+
setDisable(!disable);
39+
};
40+
3641
function fetchPort(port, link) {
3742
server.GET(server.peripheralPath(device, `${link}/${port.href}`), (data) => {
3843
const ep = parseInt(port.href.slice(-1), 10);
@@ -46,7 +51,6 @@ function ACPUTable({ device, update, notify }) {
4651
function fetchAcpuData(link) {
4752
if (link !== '') {
4853
server.GET(server.peripheralPath(device, link), (data) => {
49-
// resolve cycling
5054
if (data.name !== acpuData.name
5155
|| data.frequency !== acpuData.frequency
5256
|| data.load !== acpuData.load) {
@@ -75,7 +79,7 @@ function ACPUTable({ device, update, notify }) {
7579
function fetchData() {
7680
server.GET(server.api.fetch(server.Elem.peripherals, device), (data) => {
7781
const acpu = getPeripherals(data, 'acpu');
78-
setDisable(acpu.length === 0);
82+
setDisable(true);
7983
if (acpu.length > 0) {
8084
const link = acpu[0].href;
8185
setHref(link);
@@ -124,7 +128,6 @@ function ACPUTable({ device, update, notify }) {
124128
}
125129

126130
const deleteRow = (index) => {
127-
// no delete method for acpu. this is just clear name of the endpoint which mean disable
128131
const val = endpoints[index].data;
129132
val.name = '';
130133
server.PATCH(server.peripheralPath(device, `${href}/ep/${endpoints[index].ep}`), val, () => fetchAcpuData(href));
@@ -147,9 +150,20 @@ function ACPUTable({ device, update, notify }) {
147150

148151
const powerHeader = ['Power', '%'];
149152
const title = 'ACPU';
153+
150154
return (
151155
<div className="component-table-head">
152156
<ComponentLabel name={title} />
157+
158+
{/* Toggle Switch for ACPU */}
159+
<div className="toggle-container">
160+
<label htmlFor="acpu-toggle">ACPU Power</label>
161+
<label className="toggle-switch">
162+
<input type="checkbox" onChange={handleToggle} checked={!disable} />
163+
<span className="slider" />
164+
</label>
165+
</div>
166+
153167
<div className="cpu-container">
154168
<PowerTable
155169
title="ACPU power"
@@ -172,28 +186,28 @@ function ACPUTable({ device, update, notify }) {
172186
<Dropdown value={acpuData.load} onChangeHandler={(value) => handleChange('load', value)} items={loadActivity} disabled={disable} />
173187
</div>
174188
</div>
189+
175190
<TableBase header={header} disabled={disable} onClick={() => setModalOpen(true)}>
176-
{
177-
endpoints.map((row, index) => (
178-
(row.data !== undefined && row.data.name !== '')
179-
&& (
180-
<tr key={row.ep}>
181-
<StatusColumn messages={row.data.consumption.messages} />
182-
<Actions
183-
onEditClick={() => { setEditIndex(index); setModalOpen(true); }}
184-
onDeleteClick={() => deleteRow(index)}
185-
/>
186-
<td>{row.data.name}</td>
187-
<SelectionCell val={row.data.activity} values={loadActivity} />
188-
<PercentsCell val={row.data.read_write_rate} />
189-
<PercentsCell val={row.data.toggle_rate} precition={1} />
190-
<BandwidthCell val={row.data.consumption.calculated_bandwidth} />
191-
<PowerCell val={row.data.consumption.noc_power} />
192-
</tr>
193-
)
194-
))
195-
}
191+
{endpoints.map((row, index) => (
192+
(row.data !== undefined && row.data.name !== '')
193+
&& (
194+
<tr key={row.ep}>
195+
<StatusColumn messages={row.data.consumption.messages} />
196+
<Actions
197+
onEditClick={() => { setEditIndex(index); setModalOpen(true); }}
198+
onDeleteClick={() => deleteRow(index)}
199+
/>
200+
<td>{row.data.name}</td>
201+
<SelectionCell val={row.data.activity} values={loadActivity} />
202+
<PercentsCell val={row.data.read_write_rate} />
203+
<PercentsCell val={row.data.toggle_rate} precition={1} />
204+
<BandwidthCell val={row.data.consumption.calculated_bandwidth} />
205+
<PowerCell val={row.data.consumption.noc_power} />
206+
</tr>
207+
)
208+
))}
196209
</TableBase>
210+
197211
{modalOpen && (
198212
<ABCPUModal
199213
title={title}

src/components/style/ACPUTable.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,55 @@
2626
padding-right: 10px;
2727
padding-left: 10px;
2828
}
29+
30+
.toggle-container {
31+
display: flex;
32+
align-items: center;
33+
gap: 0.5rem;
34+
margin-bottom: 0.5rem;
35+
margin-left: 0.3rem;
36+
width: 100%;
37+
}
38+
39+
.toggle-label {
40+
flex-grow: 1;
41+
margin-left: 0.5rem;
42+
}
43+
44+
.toggle-switch {
45+
position: relative;
46+
width: 35px;
47+
height: 18px;
48+
}
49+
50+
.slider {
51+
position: absolute;
52+
cursor: pointer;
53+
top: 0;
54+
left: 0;
55+
right: 0;
56+
bottom: 0;
57+
background-color: #ccc;
58+
transition: 0.4s;
59+
border-radius: 18px;
60+
}
61+
62+
.slider:before {
63+
position: absolute;
64+
content: "";
65+
height: 14px;
66+
width: 14px;
67+
border-radius: 50%;
68+
left: 2px;
69+
bottom: 2px;
70+
background-color: white;
71+
transition: 0.4s;
72+
}
73+
74+
input:checked + .slider {
75+
background-color: #4CAF50;
76+
}
77+
78+
input:checked + .slider:before {
79+
transform: translateX(17px);
80+
}

0 commit comments

Comments
 (0)