Skip to content

Commit

Permalink
feat(triton-linalg): modify code style
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangqirui committed Jul 5, 2024
1 parent 1085b55 commit 33bb258
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 711 deletions.
21 changes: 14 additions & 7 deletions .github/ci_script/combine_log.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import time
import sys
import os
import argparse
'''
Get info.
Get the result information fed back from the job server. If it is 'success' or 'failed', exit the pipeline. Otherwise, continue to monitor job information every 2 seconds.
output_path: the target file that you want to combine sub log with.
list_path: the list of sub log name. When it is updated, the correspondding file will be add to output tail.
list_dir_path: the dir path where sub logs stored.
status_path: the path of status file. When status file is written to "success" or "fail", exit script.
'''

output_path = sys.argv[1]
list_path = sys.argv[2]
list_dir_path = sys.argv[3]
status_path = sys.argv[4]

if __name__ == '__main__':
def combine_log(output_path, list_path, list_dir_path, status_path):
# list_pos stores the last position that pointer of list file pointed to.
list_pos = 0
while True:
Expand Down Expand Up @@ -43,3 +39,14 @@
break
else:
time.sleep(2)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Monitor and concatenate files based on a list.")
parser.add_argument('output_path', type=str, help='The path to the output file.')
parser.add_argument('list_path', type=str, help='The path to the list file containing sub-paths.')
parser.add_argument('list_dir_path', type=str, help='The base directory where sub-paths are located.')
parser.add_argument('status_path', type=str, help='The path to the status file.')

args = parser.parse_args()
combine_log(args.output_path, args.list_path, args.list_dir_path, args.status_path)

12 changes: 9 additions & 3 deletions .github/ci_script/file_guard.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import time
import sys
import os
guard_status_file = sys.argv[1]
guard_log_file = sys.argv[2]

if __name__ == '__main__':
def file_guard():
# where stores the last position that pointer pointed to.
where= 0
while True:
Expand All @@ -29,3 +27,11 @@
exit(-1)
# sleep for a while
time.sleep(2)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Monitor a log file and echo lines, check status to stop.")
parser.add_argument('guard_status_file', type=str, help='The path to the status file.')
parser.add_argument('guard_log_file', type=str, help='The path to the log file.')

args = parser.parse_args()

file_guard(args.guard_status_file, args.guard_log_file)
29 changes: 9 additions & 20 deletions .github/ci_script/triton-linalg-ci_script.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
# /bin/bash
# get PR id
# Get PR id
PR_string=$(echo $GITHUB_REF | grep -Eo "/[0-9]*/")
pr_id=(${PR_string//// })

# generate time stamp
# Generate time stamp
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
currentTimeStamp=$((timeStamp*1000+10#`date "+%N"`/1000000))

# temporally set to mlu370
# Temporally set to mlu370
card_type="MLU370-S4"

# default repo name
# Default repo name
repo_name="triton-linalg"
# repo ci root path
# Repo ci root path
repo_root="/home/user1/${repo_name}_ci/"
if [ ! -d $repo_root ];then
mkdir $repo_root
fi
# repo ci requests path
# Repo ci requests path
requests_path="$repo_root/requests"
if [ ! -d $requests_path ];then
mkdir $requests_path
fi

# gen name of this ci
# Gen name of this ci
request_name="${repo_name}_${pr_id}_${currentTimeStamp}_${card_type}.rqt"

# gen file and dir for this request
# Gen file and dir for this request
request_root="$repo_root/$request_name/"
sub_logs_path="$request_root/sub_logs/"


# echo "${repo_root}"
# echo "${requests_path}"
# echo "${request_root}"

if [ ! -d $request_root ];then
mkdir $request_root
fi
Expand All @@ -59,26 +55,19 @@ fi

chmod o+w "$request_root/log_list"

# gen request file.
#echo "${repo_name},${pr_id},${currentTimeStamp},${card_type}" > "$requests_path/${request_name}"
# Gen request file.

echo "repo:${repo_name}" > "$requests_path/${request_name}"
echo "pr_id:${pr_id}" >> "$requests_path/${request_name}"
echo "timestamp:${currentTimeStamp}" >> "$requests_path/${request_name}"

# change dir group for server and client, or when server/client try to delete request, ftp may raise error.

#chgrp -R ftpuser $request_root
#chgrp -R ftpuser $requests_path

# start script
python3 .github/ci_script/file_guard.py "$request_root/status" "$request_root/log" &
python3 .github/ci_script/combine_log.py "$request_root/log" "$request_root/log_list" "$request_root/sub_logs" "$request_root/status" &

wait

# status=$(cat ${request_root}/status)

status=$( head -n +1 ${request_root}/status )

if [ "$status" != "success" ];then
Expand Down
9 changes: 0 additions & 9 deletions tools/scripts/lint_check/IWYU.md

This file was deleted.

121 changes: 0 additions & 121 deletions tools/scripts/lint_check/format_checker.py

This file was deleted.

Loading

0 comments on commit 33bb258

Please sign in to comment.