Skip to content

Commit

Permalink
fs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
John Major committed Aug 7, 2024
1 parent 0132f01 commit c083ac6
Show file tree
Hide file tree
Showing 17 changed files with 879 additions and 514 deletions.
1 change: 1 addition & 0 deletions bloom_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- jq
- fd-find
- rclone
- gunicorn
- pip:
- zebra_day==0.3.4
- fedex_tracking_day==0.2.8
Expand Down
62 changes: 62 additions & 0 deletions bloom_lims/bin/kill_proc_holding_port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Function to kill processes by port
kill_processes_by_port() {
local port=$1
local pids=$(lsof -t -i:$port)

if [ -z "$pids" ]; then
echo "No processes found running on port $port."
return
fi

echo "Found processes running on port $port: $pids"

echo "Sending SIGTERM to processes..."
for pid in $pids; do
sudo kill -TERM $pid
done

# Wait for a moment to ensure processes receive the signal
sleep 2

echo "Sending SIGKILL to processes..."
for pid in $pids; do
sudo kill -KILL $pid
done

# Wait for a moment to ensure processes are killed
sleep 2

echo "Using fuser to release port $port..."
sudo fuser -k $port/tcp

# Verify if any processes are still running on the port
remaining_pids=$(lsof -t -i:$port)
if [ -z "$remaining_pids" ]; then
echo "All processes on port $port have been terminated."
else
echo "Processes still running on port $port: $remaining_pids"
echo "Attempting to kill remaining processes with SIGKILL..."
for pid in $remaining_pids; do
sudo kill -KILL $pid
done
fi

# Final check
final_pids=$(lsof -t -i:$port)
if [ -z "$final_pids" ]; then
echo "All processes on port $port have been terminated."
else
echo "Failed to terminate processes: $final_pids"
fi
}

# Check if a port is provided
if [ -z "$1" ]; then
echo "Usage: $0 <port>"
exit 1
fi

# Run the function to kill processes on the specified port
kill_processes_by_port $1
32 changes: 28 additions & 4 deletions bloom_lims/bobjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,27 @@ def query_instance_by_component_v2(


# should abstract to not assume properties key
def get_unique_property_values(self, property_key):
def get_unique_property_values(self, property_key, super_type=None, btype=None, b_sub_type=None, version=None):

json_path = property_key.split("->")

# Start building the query with the base table
query = self.session.query(
self.Base.classes.generic_instance
)

# Add filters based on the provided arguments
if super_type:
query = query.filter(self.Base.classes.generic_instance.super_type == super_type)
if btype:
query = query.filter(self.Base.classes.generic_instance.btype == btype)
if b_sub_type:
query = query.filter(self.Base.classes.generic_instance.b_sub_type == b_sub_type)
if version:
query = query.filter(self.Base.classes.generic_instance.version == version)

# Add the JSON path extraction and distinct filtering after the base filters
query = query.with_entities(
func.distinct(
func.jsonb_extract_path_text(
self.Base.classes.generic_instance.json_addl['properties'], *json_path
Expand All @@ -713,11 +731,17 @@ def get_unique_property_values(self, property_key):
func.jsonb_extract_path_text(
self.Base.classes.generic_instance.json_addl['properties'], *json_path
).isnot(None)
).all()
)

# Execute the query and get the results
results = query.all()

# Extract unique values from the query results
unique_values = [value[0] for value in results if value[0] is not None]

unique_values = [value[0] for value in query if value[0] is not None]
return unique_values


def query_template_by_component_v2(
self, super_type=None, btype=None, b_sub_type=None, version=None
):
Expand Down Expand Up @@ -2862,7 +2886,7 @@ def create_file(
else:
logging.warning(f"No data provided for file creation: {file_data, url}")
new_file.bstatus = "no file data provided"
self.session.commit()
self.session.commit()

if create_locked:
self.lock_file(new_file.euid)
Expand Down
19 changes: 17 additions & 2 deletions bloom_lims/config/file/file_set.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@
"1.0": {
"description": "Generic File Set",
"properties": {
"name": "A Generic File Set",
"name": "",
"comments": "",
"lab_code":"",
"tag":"",
"description":""
"tags":[],
"duration":"",
"ref_type":"",
"description":"",
"creating_user": "",
"rclone_config": {}
},
"ui_form_properties" : [
{"property_key":"name","form_label":"Set Name", "required": false, "value_type": "string"},
{"property_key":"description","form_label":"Set Description", "required": false, "value_type":"string"},
{"property_key":"tag","form_label":"Tag", "required": false, "value_type":"uid-interactive"},
{"property_key":"tags","form_label":"Tags", "required": false, "value_type":"list"},
{"property_key": "creating_user", "form_label":"Creating User", "required":false, "value_type":"uid-static"},
{"property_key": "ref_type", "form_label":"Ref Type", "required":false, "value_type":"query-only-uid-statuc"},
{"property_key": "comments", "form_label": "Comments", "required": false, "value_type": "string"}
],
"controlled_properties": { },
"expected_inputs": [],
"expected_outputs": [],
"singleton": "0",
Expand Down
4 changes: 2 additions & 2 deletions bloom_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import sys
import os

bobdb = BloomObj(BLOOMdb3())
bob = BloomObj(BLOOMdb3())


from IPython import embed
embed()
embed()
Loading

0 comments on commit c083ac6

Please sign in to comment.