Skip to content

Commit 2d848fa

Browse files
run.sh now part of the package; bump version: 0.1.4
1 parent 3e356f3 commit 2d848fa

4 files changed

Lines changed: 37 additions & 40 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
run: |
3939
mkdir -p release_files/conf
4040
cp conf/*.dist release_files/conf/
41-
cp run.sh release_files/
4241
cd release_files
4342
zip -r ../additional_assets.zip .
4443
cd ..

docs/RELEASE_MANAGEMENT.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Each release includes the following artifacts:
1313
2. **Additional Assets Archive (`additional_assets.zip`)**
1414
- `conf/lucene_query.json.dist` - Query template for Elasticsearch
1515
- `conf/platform_problem_monitoring_core.conf.dist` - Main configuration file template
16-
- `run.sh` - Main execution script
1716

1817
## Release Workflow
1918

@@ -28,19 +27,6 @@ The release process uses a GitHub Actions workflow (`.github/workflows/release.y
2827

2928
The workflow is triggered whenever a tag with the format `v*.*.*` is pushed to the repository.
3029

31-
### Required Files
32-
33-
Make sure the following files are included in your repository:
34-
35-
```
36-
.github/workflows/release.yml # Release workflow definition
37-
conf/lucene_query.json.dist # Elasticsearch query template
38-
conf/platform_problem_monitoring_core.conf.dist # Configuration template
39-
src/platform_problem_monitoring_core/resources/html_email_template.html # Email template
40-
run.sh # Main execution script
41-
Makefile # Development utilities
42-
```
43-
4430
## Step-by-Step Release Process
4531

4632
### 1. Prepare for Release

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "platform_problem_monitoring_core"
7-
version = "0.1.3"
7+
version = "0.1.4"
88
description = "A tool for monitoring platform problems using Elasticsearch logs"
99
authors = [
1010
{name = "Platform Team"}
@@ -44,12 +44,11 @@ package-dir = {"" = "src"}
4444

4545
# Add package data to include resources in the wheel
4646
[tool.setuptools.package-data]
47-
platform_problem_monitoring_core = ["resources/*.html"]
47+
platform_problem_monitoring_core = ["resources/*.html", "bin/*"]
4848

4949
# Add data files to include configuration templates
5050
[tool.setuptools.data-files]
5151
"conf" = ["conf/*.dist"]
52-
"." = ["run.sh"]
5352

5453
[tool.black]
5554
line-length = 120

run.sh renamed to src/platform_problem_monitoring_core/bin/run.sh

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ fi
2020
# Source the configuration file
2121
source "$CONFIG_FILE"
2222

23-
2423
# Step 0: Prepare Python environment
2524
echo "Step 0: Preparing Python environment..."
2625

@@ -41,19 +40,33 @@ while [ -L "$SOURCE" ]; do
4140
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
4241
done
4342

44-
SCRIPT_FOLDER=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
45-
if [ -z "$SCRIPT_FOLDER" ]; then
46-
echo "Failed to determine script folder" >&2
47-
exit 1
48-
fi
43+
# Get the script directory and the package root (2 levels up)
44+
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
45+
PACKAGE_ROOT=$( cd -P "$SCRIPT_DIR/../.." >/dev/null 2>&1 && pwd )
4946

50-
cd "$SCRIPT_FOLDER"
51-
/usr/bin/env python3 -m venv venv
52-
source venv/bin/activate
47+
echo "Script directory: $SCRIPT_DIR"
48+
echo "Package root directory: $PACKAGE_ROOT"
5349

54-
pip install --upgrade pip
55-
pip install -e . -q
50+
# Set up Python environment
51+
# If running from installed package:
52+
if python -c "import platform_problem_monitoring_core" &>/dev/null; then
53+
echo "Running from installed package"
54+
PYTHON_CMD="python"
55+
else
56+
# If running from source, create and use virtual environment
57+
echo "Running from source, setting up virtual environment"
58+
cd "$PACKAGE_ROOT"
5659

60+
if [ ! -d "venv" ]; then
61+
echo "Creating virtual environment"
62+
python3 -m venv venv
63+
fi
64+
65+
source venv/bin/activate
66+
pip install --upgrade pip
67+
pip install -e . -q
68+
PYTHON_CMD="python"
69+
fi
5770

5871
# Define file paths for intermediate results
5972
WORK_DIR=""
@@ -74,7 +87,7 @@ echo "Starting Platform Problem Monitoring process..."
7487
# Step 1: Prepare application environment
7588
echo "Step 1: Preparing application environment..."
7689
# Capture all output but only use the last line as the work directory
77-
PREPARE_OUTPUT=$(python -m platform_problem_monitoring_core.step1_prepare)
90+
PREPARE_OUTPUT=$($PYTHON_CMD -m platform_problem_monitoring_core.step1_prepare)
7891
if [ $? -ne 0 ]; then
7992
echo "Error: Failed to prepare environment"
8093
exit 1
@@ -100,7 +113,7 @@ TREND_CHART_FILE="$WORK_DIR/trend_chart.png"
100113

101114
# Step 2: Download previous state
102115
echo "Step 2: Downloading previous state..."
103-
python -m platform_problem_monitoring_core.step2_download_previous_state \
116+
$PYTHON_CMD -m platform_problem_monitoring_core.step2_download_previous_state \
104117
--s3-bucket "$REMOTE_STATE_S3_BUCKET_NAME" \
105118
--s3-folder "$REMOTE_STATE_S3_FOLDER_NAME" \
106119
--date-time-file "$START_DATE_TIME_FILE" \
@@ -113,7 +126,7 @@ echo "Previous state downloaded successfully"
113126

114127
# Step 3: Retrieve hourly problem numbers
115128
echo "Step 3: Retrieving hourly problem numbers..."
116-
python -m platform_problem_monitoring_core.step3_retrieve_hourly_problem_numbers \
129+
$PYTHON_CMD -m platform_problem_monitoring_core.step3_retrieve_hourly_problem_numbers \
117130
--elasticsearch-url "$ELASTICSEARCH_SERVER_BASE_URL" \
118131
--query-file "$ELASTICSEARCH_LUCENE_QUERY_FILE_PATH" \
119132
--hours-back "${TREND_HOURS_BACK:-24}" \
@@ -126,7 +139,7 @@ echo "Hourly problem numbers retrieved successfully"
126139

127140
# Step 4: Generate trend chart
128141
echo "Step 4: Generating trend chart..."
129-
python -m platform_problem_monitoring_core.step4_generate_trend_chart \
142+
$PYTHON_CMD -m platform_problem_monitoring_core.step4_generate_trend_chart \
130143
--hourly-data-file "$HOURLY_DATA_FILE" \
131144
--output-file "$TREND_CHART_FILE"
132145
if [ $? -ne 0 ]; then
@@ -137,7 +150,7 @@ echo "Trend chart generated successfully"
137150

138151
# Step 5: Download logstash documents
139152
echo "Step 5: Downloading logstash documents..."
140-
python -m platform_problem_monitoring_core.step5_download_logstash_documents \
153+
$PYTHON_CMD -m platform_problem_monitoring_core.step5_download_logstash_documents \
141154
--elasticsearch-url "$ELASTICSEARCH_SERVER_BASE_URL" \
142155
--query-file "$ELASTICSEARCH_LUCENE_QUERY_FILE_PATH" \
143156
--start-date-time-file "$START_DATE_TIME_FILE" \
@@ -151,7 +164,7 @@ echo "Logstash documents downloaded successfully"
151164

152165
# Step 6: Extract fields from logstash documents
153166
echo "Step 6: Extracting fields from logstash documents..."
154-
python -m platform_problem_monitoring_core.step6_extract_fields \
167+
$PYTHON_CMD -m platform_problem_monitoring_core.step6_extract_fields \
155168
--logstash-file "$LOGSTASH_DOCUMENTS_FILE" \
156169
--output-file "$EXTRACTED_FIELDS_FILE"
157170
if [ $? -ne 0 ]; then
@@ -162,7 +175,7 @@ echo "Fields extracted successfully"
162175

163176
# Step 7: Normalize messages
164177
echo "Step 7: Normalizing messages..."
165-
python -m platform_problem_monitoring_core.step7_normalize_messages \
178+
$PYTHON_CMD -m platform_problem_monitoring_core.step7_normalize_messages \
166179
--fields-file "$EXTRACTED_FIELDS_FILE" \
167180
--output-file "$NORM_RESULTS_FILE"
168181
if [ $? -ne 0 ]; then
@@ -173,7 +186,7 @@ echo "Messages normalized successfully"
173186

174187
# Step 8: Compare normalizations
175188
echo "Step 8: Comparing normalization results..."
176-
python -m platform_problem_monitoring_core.step8_compare_normalizations \
189+
$PYTHON_CMD -m platform_problem_monitoring_core.step8_compare_normalizations \
177190
--current-file "$NORM_RESULTS_FILE" \
178191
--previous-file "$NORM_RESULTS_PREV_FILE" \
179192
--output-file "$COMPARISON_RESULTS_FILE"
@@ -185,7 +198,7 @@ echo "Normalization results compared successfully"
185198

186199
# Step 9: Generate email bodies
187200
echo "Step 9: Generating email bodies..."
188-
python -m platform_problem_monitoring_core.step9_generate_email_bodies \
201+
$PYTHON_CMD -m platform_problem_monitoring_core.step9_generate_email_bodies \
189202
--comparison-file "$COMPARISON_RESULTS_FILE" \
190203
--norm-results-file "$NORM_RESULTS_FILE" \
191204
--html-output "$HTML_EMAIL_BODY_FILE" \
@@ -205,7 +218,7 @@ echo "Email bodies generated successfully"
205218
# Step 10: Send email report
206219
echo "Step 10: Sending email report..."
207220
EMAIL_SUBJECT="Platform Problem Monitoring Report $(date +"%Y-%m-%d")"
208-
python -m platform_problem_monitoring_core.step10_send_email_report \
221+
$PYTHON_CMD -m platform_problem_monitoring_core.step10_send_email_report \
209222
--html-file "$HTML_EMAIL_BODY_FILE" \
210223
--text-file "$TEXT_EMAIL_BODY_FILE" \
211224
--subject "$EMAIL_SUBJECT" \
@@ -223,7 +236,7 @@ echo "Email report sent successfully"
223236

224237
# Step 11: Store new state
225238
echo "Step 11: Storing new state..."
226-
python -m platform_problem_monitoring_core.step11_store_new_state \
239+
$PYTHON_CMD -m platform_problem_monitoring_core.step11_store_new_state \
227240
--s3-bucket "$REMOTE_STATE_S3_BUCKET_NAME" \
228241
--s3-folder "$REMOTE_STATE_S3_FOLDER_NAME" \
229242
--date-time-file "$CURRENT_DATE_TIME_FILE" \

0 commit comments

Comments
 (0)