-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Add Pylint gitaction for gitaction ci
Add pylint yml file for python lint - we move to gitaction from TAOS CI - using pylint file from tensorflow gitaction - ref : https://github.com/tensorflow/tensorflow/blob/master/.github/workflows/pylint-presubmit.yml - and for test : fix python file's format **Changes proposed in this PR:** - pylint.yml **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghak PARK <[email protected]>
- Loading branch information
1 parent
4a7f3c2
commit f3392ab
Showing
2 changed files
with
109 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2021 The TensorFlow Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
|
||
name: PyLint | ||
on: | ||
pull_request: | ||
paths: | ||
- '**.py' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: PyLint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Get file changes | ||
id: get_file_changes | ||
uses: trilom/[email protected] | ||
with: | ||
output: ' ' | ||
- name: Report list of changed files | ||
run: | | ||
echo Changed files: ${{ steps.get_file_changes.outputs.files }} | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint==3.0.2 numpy wheel | ||
- name: Run PyLint on changed files | ||
run: | | ||
echo "${{ steps.get_file_changes.outputs.files}}" | tr " " "\n" | grep ".py$" | xargs pylint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,52 @@ | ||
#!/usr/bin/env python | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Copyright (C) 2020 Jijoong Moon <[email protected]> | ||
# | ||
# @file dataset.py | ||
# @date 15 July 2020 | ||
# @brief This is for mnist input generation | ||
# @see https://github.com/nnstreamer/nntrainer | ||
# @author Jijoong Moon <[email protected]> | ||
# @bug No known bugs except for NYI items | ||
# | ||
# | ||
""" | ||
SPDX-License-Identifier: Apache-2.0 | ||
Copyright (C) 2020 Jijoong Moon <[email protected]> | ||
@file dataset.py | ||
@date 15 July 2020 | ||
@brief This is for mnist input generation | ||
@see https://github.com/nnstreamer/nntrainer | ||
@author Jijoong Moon <[email protected]> | ||
@bug No known bugs except for NYI items | ||
""" | ||
|
||
|
||
import struct | ||
import os | ||
import numpy as np | ||
|
||
TOTAL_TRAIN_DATA_SIZE=100 | ||
TOTAL_LABEL_SIZE=100 | ||
TOTAL_VAL_DATA_SIZE=20 | ||
TOTAL_TRAIN_DATA_SIZE = 100 | ||
TOTAL_LABEL_SIZE = 100 | ||
TOTAL_VAL_DATA_SIZE = 20 | ||
FEATURE_SIZE = 3072 | ||
|
||
def get_data_info(target): | ||
|
||
def get_data_info(): | ||
"""Return Data size | ||
Returns: | ||
t_data_size, v_data_size, TOTAL_LABEL_SIZE, FEATURE_SIZE | ||
""" | ||
t_data_size = TOTAL_TRAIN_DATA_SIZE | ||
v_data_size = TOTAL_VAL_DATA_SIZE | ||
return t_data_size, v_data_size, TOTAL_LABEL_SIZE, FEATURE_SIZE | ||
|
||
## | ||
# @brief load input data from file | ||
# @return (InputVector, InputLabel, Validation Vector, ValidationLabel) | ||
|
||
|
||
def load_data(target): | ||
"""Load data && save as file | ||
Args: | ||
target (str): train || validation | ||
Returns: | ||
input_vector, input_label, val_vector, val_label | ||
""" | ||
# data_size = TOTAL_TRAIN_DATA_SIZE; | ||
d_size = get_data_info(target) | ||
d_size = get_data_info() | ||
|
||
if target == "validation": | ||
t_buf_size = d_size[0] | ||
|
@@ -40,33 +55,33 @@ def load_data(target): | |
t_buf_size = d_size[0]*TOTAL_LABEL_SIZE | ||
v_buf_size = d_size[1]*TOTAL_LABEL_SIZE | ||
|
||
InputVector = np.zeros((t_buf_size, FEATURE_SIZE),dtype=np.float32) | ||
InputLabel = np.zeros((t_buf_size, TOTAL_LABEL_SIZE),dtype=np.float32) | ||
input_vector = np.zeros((t_buf_size, FEATURE_SIZE), dtype=np.float32) | ||
input_label = np.zeros((t_buf_size, TOTAL_LABEL_SIZE), dtype=np.float32) | ||
|
||
ValVector = np.zeros((v_buf_size,FEATURE_SIZE),dtype=np.float32) | ||
ValLabel = np.zeros((v_buf_size, TOTAL_LABEL_SIZE),dtype=np.float32) | ||
val_vector = np.zeros((v_buf_size, FEATURE_SIZE), dtype=np.float32) | ||
val_label = np.zeros((v_buf_size, TOTAL_LABEL_SIZE), dtype=np.float32) | ||
|
||
#read Input & Label | ||
# read Input & Label | ||
|
||
fin = open('vgg_valSet.dat','rb') | ||
for i in range(v_buf_size): | ||
for j in range(FEATURE_SIZE): | ||
data_str = fin.read(4) | ||
ValVector[i,j] = struct.unpack('f',data_str)[0] | ||
for j in range(TOTAL_LABEL_SIZE): | ||
data_str = fin.read(4) | ||
ValLabel[i,j] = struct.unpack('f',data_str)[0] | ||
fin.close() | ||
with open('vgg_valSet.dat', 'rb') as fin: | ||
for i in range(v_buf_size): | ||
for j in range(FEATURE_SIZE): | ||
data_str = fin.read(4) | ||
val_vector[i, j] = struct.unpack('f', data_str)[0] | ||
for j in range(TOTAL_LABEL_SIZE): | ||
data_str = fin.read(4) | ||
val_label[i, j] = struct.unpack('f', data_str)[0] | ||
fin.close() | ||
|
||
# we are using same training data for validation to check how internal implementation is working | ||
fin=open('vgg_trainingSet.dat','rb') | ||
for i in range(t_buf_size): | ||
for j in range(FEATURE_SIZE): | ||
data_str = fin.read(4) | ||
InputVector[i,j] = struct.unpack('f',data_str)[0] | ||
for j in range(TOTAL_LABEL_SIZE): | ||
data_str = fin.read(4) | ||
InputLabel[i,j] = struct.unpack('f',data_str)[0] | ||
fin.close() | ||
|
||
return InputVector, InputLabel, ValVector, ValLabel | ||
with open('vgg_trainingSet.dat', 'rb') as fin: | ||
for i in range(t_buf_size): | ||
for j in range(FEATURE_SIZE): | ||
data_str = fin.read(4) | ||
input_vector[i, j] = struct.unpack('f', data_str)[0] | ||
for j in range(TOTAL_LABEL_SIZE): | ||
data_str = fin.read(4) | ||
input_label[i, j] = struct.unpack('f', data_str)[0] | ||
fin.close() | ||
|
||
return input_vector, input_label, val_vector, val_label |