56771308a6283f9b301c547acf990f72513cc43a
update amendments in tables.sql to include job_id in entry_ammendment added amend.py to move amendment-related code into its own file when we create a job (NewJob) and that job matches an amendmentType (via job_name or job_name:amt <- where amt relates to how we do a transform_image), then we enter a new EntryAmendment pa_job_mgr knows when a Transform job ends, and removes relevant EntryAmendment files*.js use EntryAmendment data to render thumbnails with relevant AmendmentType if a normal page load (like /files_ip), and there is an EntryAmendment, mark up the thumb, run the check jobs to look for completion of the job, removeal of the EntryAmendment and update the entry based on 'transformed' image OVERALL: this is a functioning version that uses EntryAmendments and can handle loading a new page with outstanding amendments and 'deals' with it. This is a good base, but does not cater for remove_files or move_files
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
In here we can put instructions on how to run this / any general info
to edit src:
git....
cd ~/src ; # or wherever you want the code to live
git clone https://git.depaoli.id.au/ddp/photoassistant.git
ubuntu packages:
sudo apt-get install -y cmake libpq-dev
AFTER a fresh ubuntu, need to remove/make a new .python env and get pip-based python packages installed into .python:
cd ~/src/photoassistant
rm .python
# use a venv (to get consistent python versions with Prod container)
python3 -m venv .python
source ./.python/bin/activate
pip3 install -r requirements.txt
upstream packages...
mkdir static/upstream
cd static/upstream
mkdir bootstrap-4.6.0-dist
cd bootstrap-4.6.0-dist
mkdir css
# for boostrap:
wget https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css
mkdir js
# to note we might need bootstrap.bundle.min.js if we use new features?
wget https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js
# for jquery
https://code.jquery.com/jquery-3.6.0.min.js
# for jquery/smart context menu
wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.css
wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js
wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.contextMenu.min.js.map
wget https://cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.9.2/jquery.ui.position.min.js
### I tried to update via pip3, with this:
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev libgirepository1.0-dev libcups2-dev
pip3 list | tail -n +3 | grep -v mysqlclient | grep -v duplicity | grep -v gpg | awk ' { print $1 } ' | xargs pip3 install --upgrade
To run debug version of web server (gunicorn deprecates FLASK_ENV, so co-exist for now):
# flask 2.2.2+ (in venv .python)
FLASK_APP=main ENV=development ./.python/bin/flask --debug run --host=mara.ddp.net
to run prod version of web server:
gunicorn --bind="mara.ddp.net:5000" --threads=2 --workers=2 main:app
Also have to run the job manager for jobs to work:
ENV="development" python3 pa_job_manager.py
To rebuild DB from scratch/empty data:
###BE CAREFUL this completely destroys the database contents and starts from
#scratch, when we get real data, we will instead cp a backup file not the
#tables.sql
( cd /srv/docker/config/ ; sudo docker-compose stop padb_dev ; yes | sudo docker-compose rm padb_dev ; sudo rm -rf /srv/docker/container/padb_dev/data/ ; sudo cp /home/ddp/src/photoassistant/tables.sql /srv/docker/container/padb_dev/docker-entrypoint-initdb.d/tables.sql ; sudo docker-compose up -d padb_dev ) &
To get back a 'working' but scanned set of data:
# make a backup and store it in DB_BACKUP:
sudo docker exec -it padb bash
root@2881f871e1c2:/# pg_dump --user=pa pa > /docker-entrypoint-initdb.d/tables.sql
cp /srv/docker/container/padb/docker-entrypoint-initdb.d/tables.sql /home/ddp/src/photoassistant/DB_BACKUP/
mv /home/ddp/src/photoassistant/DB_BACKUP/tables.sql /home/ddp/src/photoassistant/DB_BACKUP/`date +%Y%m%d-tables.sql`
gzip /home/ddp/src/photoassistant/DB_BACKUP/`date +%Y%m%d-tables.sql`
# mv /home/ddp/src/photoassistant/DB_BACKUP/`date +%Y%m%d-tables.sql`.gz /home/ddp/src/photoassistant/DB_BACKUP/<meaningfulname>......
# start db, using new tables.sql
DEV:
( cd /srv/docker/config/ ; sudo docker-compose stop padb_dev ; sudo docker-compose rm -f padb_dev ; sudo rm -rf /srv/docker/container/padb_dev/data/ ; sudo cp /home/ddp/src/photoassistant/tables.sql /srv/docker/container/padb_dev/docker-entrypoint-initdb.d/tables.sql ; sudo docker-compose up -d padb_dev )
### decide what tables.sql you want, e.g.
sudo bash
# gunzip -c /home/ddp/src/photoassistant/DB_BACKUP/20200126-all-imported-no-duplicates.sql.gz > /srv/docker/container/padb/docker-entrypoint-initdb.d/tables.sql
#PROD!!!!!
( cd /srv/docker/config/ ; sudo docker-compose stop padb ; yes | sudo docker-compose rm padb ; sudo rm -rf /srv/docker/container/padb/data/ ; sudo docker-compose up -d padb )
# export just person/refimg so we don't have to recreate them by hand between refreshes of DB
sudo docker exec -it padb bash
# pg_dump --user=pa -a -t person -t refimg -t person_refimg_link > /docker-entrypoint-initdb.d/users.sql
# export all content so we can upgrade versions of postgres
docker exec -it padb bash
# pg_dump --user=pa pa > /docker-entrypoint-initdb.d/bkup.sql
### check sql looks good
sudo mv /srv/docker/container/padb/docker-entrypoint-initdb.d/bkup.sql /srv/docker/container/padb/docker-entrypoint-initdb.d/tables.sql
sudo rm /srv/docker/container/padb/docker-entrypoint-initdb.d/users.sql
docker-compose -f /srv/docker/config/docker-compose.yaml build padb
( cd /srv/docker/config/ ; docker-compose stop padb ; yes | docker-compose rm padb ; sudo rm -rf /srv/docker/container/padb/data/ ; docker-compose up -d padb ; docker-compose restart paweb )
HANDY SQLs/commands:
# long-running AI job (in this case #46), which is not committing joblog per file, and isnt tracking counts properly (temporary bug)
sudo docker exec -it padb bash
echo 'select * from joblog where job_id = 46;' | psql --user=pa pa | grep 'ooking for' | awk '{ print $15 } ' | sort -u | wc -l
# how many entries are in a path
sudo docker exec -it padb bash
psql --user=pa pa
select count(entry_id) from entry_dir_link where dir_eid in ( select distinct dir_eid from path_dir_link where path_id = 2 );
# how many Images are in a path
sudo docker exec -it padb bash
psql --user=pa pa
select count(distinct e.id) from entry e, entry_dir_link edl where e.type_id = 1 and e.id = edl.entry_id and edl.dir_eid in ( select distinct dir_eid from path_dir_link where path_id = 2 );
# get abs filenames of matching files (for liz person.tag, but could easily add
# d.rel_path like 'liz' too :
select '"'||replace(replace(p.path_prefix,'static/Storage/',''),'static/Import/', '')||'/'||d.rel_path||'/'||e.name||'"' from entry e, entry_dir_link edl, path_dir_link pdl, path p, dir d where e.id = edl.entry_id and edl.dir_eid = pdl.dir_eid and pdl.path_id = p.id and d.eid = edl.dir_eid and e.id in ( select e.id from entry e, face_file_link ffl, face_refimg_link frl, person_refimg_link prl, person p where e.id = ffl.file_eid and ffl.face_id = frl.face_id and frl.refimg_id = prl.refimg_id and prl.person_id = p.id and p.tag = 'liz' );
Description
PhotoAssistant - allows me to remove duplicate photos, more easily create folders to store common photos and uses python AI libraries to find faces and allows searching across all
Languages
Python
67.5%
HTML
22.1%
JavaScript
9.3%
Shell
0.7%
Dockerfile
0.4%