Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions .github/workflows/rpe_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- ubuntu-22.04 # This is CentOS 7 under the hood
- ubuntu-22.04
- macos-12
- windows-latest
runs-on: ${{ matrix.os }}
Expand All @@ -33,13 +33,12 @@ jobs:
if: ${{ matrix.os != 'ubuntu-22.04' }}
uses: actions/setup-node@v4
with:
node-version: 20.11 #if update this then also update in Dockerfile for centos
node-version: 20.11

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

- name: Login to the Container registry
if: ${{ matrix.os == 'ubuntu-22.04' }}
Expand All @@ -59,13 +58,13 @@ jobs:
node --version
python3 -V

- name: Shell configuration on centos 7
- name: Shell configuration on CentOS 7
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: addnab/docker-run-action@v3
with:
shell: bash
image: ghcr.io/${{ github.repository_owner }}/rapid_power_estimator:centos7latest
run:
run: |
source /opt/rh/devtoolset-11/enable
cmake --version
node --version
Expand All @@ -82,7 +81,7 @@ jobs:
run: |
npx eslint src/

- name: Install packages centos 7 & Run pytest & frontend test
- name: Install packages CentOS 7 & Run pytest & frontend test
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: addnab/docker-run-action@v3
with:
Expand Down Expand Up @@ -111,7 +110,7 @@ jobs:
fail-fast: false
matrix:
os:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you removed this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NadeemYaseen I will add the comments again since I shall re-push the entire file by doing a new PR, I need your comments/approval on the steps to install python on virtual environment, especially from line 238 to line 255.

- ubuntu-22.04 # This is CentOS 7 under the hood
- ubuntu-22.04
- macos-12
- windows-latest
runs-on: ${{ matrix.os }}
Expand All @@ -128,13 +127,12 @@ jobs:
if: ${{ matrix.os != 'ubuntu-22.04' }}
uses: actions/setup-node@v4
with:
node-version: 20.11 #if update this then also update in Dockerfile for centos
node-version: 20.11

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

- name: Login to the Container registry
if: ${{ matrix.os == 'ubuntu-22.04' }}
Expand All @@ -154,7 +152,7 @@ jobs:
node --version
python3 -V

- name: Shell configuration on centos 7
- name: Shell configuration on CentOS 7
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: addnab/docker-run-action@v3
with:
Expand Down Expand Up @@ -215,14 +213,12 @@ jobs:
name: rapid_power_estimator_${{ matrix.os }}
path: dist/rapid_power_estimator*.exe


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


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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Set up virtual environment
run: |
python3 -m venv venv
source venv/bin/activate

- name: Install dependencies
run: |
pip install -r requirements.txt
npm install
- name: Install dependencies in virtual environment
run: |
source venv/bin/activate
pip install -r requirements.txt
npm install

- name: Run pytest with Codecov
run: python3 -m pytest --cov=. --cov-report=term-missing
run: |
source venv/bin/activate
python3 -m pytest --cov=. --cov-report=term-missing

- name: Upload results to Codecov
uses: codecov/codecov-action@v4
Expand All @@ -261,4 +267,4 @@ jobs:
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: os-fpga/rapid_power_estimator
slug: os-fpga/rapid_power_estimator
60 changes: 37 additions & 23 deletions src/components/Tables/ACPUTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
const [disable, setDisable] = React.useState(true);
const loadActivity = GetOptions('A45_Load');

// Toggle handler to enable/disable ACPU fields
const handleToggle = () => {
setDisable(!disable);

Check warning on line 38 in src/components/Tables/ACPUTable.js

View check run for this annotation

Codecov / codecov/patch

src/components/Tables/ACPUTable.js#L38

Added line #L38 was not covered by tests
};

function fetchPort(port, link) {
server.GET(server.peripheralPath(device, `${link}/${port.href}`), (data) => {
const ep = parseInt(port.href.slice(-1), 10);
Expand All @@ -46,7 +51,6 @@
function fetchAcpuData(link) {
if (link !== '') {
server.GET(server.peripheralPath(device, link), (data) => {
// resolve cycling
if (data.name !== acpuData.name
|| data.frequency !== acpuData.frequency
|| data.load !== acpuData.load) {
Expand Down Expand Up @@ -75,7 +79,7 @@
function fetchData() {
server.GET(server.api.fetch(server.Elem.peripherals, device), (data) => {
const acpu = getPeripherals(data, 'acpu');
setDisable(acpu.length === 0);
setDisable(true);

Check warning on line 82 in src/components/Tables/ACPUTable.js

View check run for this annotation

Codecov / codecov/patch

src/components/Tables/ACPUTable.js#L82

Added line #L82 was not covered by tests
if (acpu.length > 0) {
const link = acpu[0].href;
setHref(link);
Expand Down Expand Up @@ -124,7 +128,6 @@
}

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

const powerHeader = ['Power', '%'];
const title = 'ACPU';

return (
<div className="component-table-head">
<ComponentLabel name={title} />

{/* Toggle Switch for ACPU */}
<div className="toggle-container">
<label htmlFor="acpu-toggle">ACPU Power</label>
<label className="toggle-switch">
<input type="checkbox" onChange={handleToggle} checked={!disable} />
<span className="slider" />
</label>
</div>

<div className="cpu-container">
<PowerTable
title="ACPU power"
Expand All @@ -172,28 +186,28 @@
<Dropdown value={acpuData.load} onChangeHandler={(value) => handleChange('load', value)} items={loadActivity} disabled={disable} />
</div>
</div>

<TableBase header={header} disabled={disable} onClick={() => setModalOpen(true)}>
{
endpoints.map((row, index) => (
(row.data !== undefined && row.data.name !== '')
&& (
<tr key={row.ep}>
<StatusColumn messages={row.data.consumption.messages} />
<Actions
onEditClick={() => { setEditIndex(index); setModalOpen(true); }}
onDeleteClick={() => deleteRow(index)}
/>
<td>{row.data.name}</td>
<SelectionCell val={row.data.activity} values={loadActivity} />
<PercentsCell val={row.data.read_write_rate} />
<PercentsCell val={row.data.toggle_rate} precition={1} />
<BandwidthCell val={row.data.consumption.calculated_bandwidth} />
<PowerCell val={row.data.consumption.noc_power} />
</tr>
)
))
}
{endpoints.map((row, index) => (
(row.data !== undefined && row.data.name !== '')

Check warning on line 192 in src/components/Tables/ACPUTable.js

View check run for this annotation

Codecov / codecov/patch

src/components/Tables/ACPUTable.js#L192

Added line #L192 was not covered by tests
&& (
<tr key={row.ep}>
<StatusColumn messages={row.data.consumption.messages} />
<Actions
onEditClick={() => { setEditIndex(index); setModalOpen(true); }}
onDeleteClick={() => deleteRow(index)}

Check warning on line 198 in src/components/Tables/ACPUTable.js

View check run for this annotation

Codecov / codecov/patch

src/components/Tables/ACPUTable.js#L197-L198

Added lines #L197 - L198 were not covered by tests
/>
<td>{row.data.name}</td>
<SelectionCell val={row.data.activity} values={loadActivity} />
<PercentsCell val={row.data.read_write_rate} />
<PercentsCell val={row.data.toggle_rate} precition={1} />
<BandwidthCell val={row.data.consumption.calculated_bandwidth} />
<PowerCell val={row.data.consumption.noc_power} />
</tr>
)
))}
</TableBase>

{modalOpen && (
<ABCPUModal
title={title}
Expand Down
52 changes: 52 additions & 0 deletions src/components/style/ACPUTable.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,55 @@
padding-right: 10px;
padding-left: 10px;
}

.toggle-container {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.5rem;
margin-left: 0.3rem;
width: 100%;
}

.toggle-label {
flex-grow: 1;
margin-left: 0.5rem;
}

.toggle-switch {
position: relative;
width: 35px;
height: 18px;
}

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: 0.4s;
border-radius: 18px;
}

.slider:before {
position: absolute;
content: "";
height: 14px;
width: 14px;
border-radius: 50%;
left: 2px;
bottom: 2px;
background-color: white;
transition: 0.4s;
}

input:checked + .slider {
background-color: #4CAF50;
}

input:checked + .slider:before {
transform: translateX(17px);
}
Loading