Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9348038
D541.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
D541.id.diff
View Options
diff --git a/MANIFEST.in b/MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,4 +3,5 @@
include requirements.txt
include requirements-swh.txt
include version.txt
+recursive-include swh/scheduler/sql *.sql
recursive-include swh/scheduler/tests/data *.sql
diff --git a/sql/Makefile b/sql/Makefile
--- a/sql/Makefile
+++ b/sql/Makefile
@@ -3,25 +3,39 @@
DBNAME = softwareheritage-scheduler-dev
DOCDIR = autodoc
-SQL_SCHEMA = swh-scheduler-schema.sql
-SQL_DATA = swh-scheduler-data.sql
+SQL_SCHEMA = 30-swh-schema.sql
+SQL_DATA = 40-swh-data.sql
SQLS = $(SQL_SCHEMA) $(SQL_DATA)
+SQL_FILES = $(abspath $(addprefix $(CURDIR)/../swh/scheduler/sql/,$(SQLS)))
PSQL_BIN = psql
PSQL_FLAGS = --echo-all -X -v ON_ERROR_STOP=1
PSQL = $(PSQL_BIN) $(PSQL_FLAGS)
+PIFPAF=$(findstring postgresql://,$(PIFPAF_URLS))
+
all:
createdb: createdb-stamp
-createdb-stamp: $(SQL_INIT)
+createdb-stamp: $(SQL_FILES)
+ifndef PIFPAF
+ -dropdb $(DBNAME)
+endif
createdb $(DBNAME)
+ifndef PIFPAF
touch $@
+else
+ rm -f $@
+endif
filldb: filldb-stamp
filldb-stamp: createdb-stamp
- cat $(SQLS) | $(PSQL) $(DBNAME)
+ cat $(SQL_FILES) | $(PSQL) $(DBNAME)
+ifndef PIFPAF
touch $@
+else
+ rm -f $@
+endif
dropdb:
-dropdb $(DBNAME)
@@ -30,15 +44,23 @@
swh-scheduler.dump: filldb-stamp
pg_dump -Fc $(DBNAME) > $@
-doc: autodoc-stamp $(DOCDIR)/swh-scheduler.pdf
-autodoc-stamp: filldb-stamp
+$(DOCDIR):
test -d $(DOCDIR)/ || mkdir $(DOCDIR)
- postgresql_autodoc -d $(DBNAME) -f $(DOCDIR)/swh
+
+doc: autodoc-stamp $(DOCDIR)/swh-scheduler.pdf
+autodoc-stamp: filldb-stamp $(DOCDIR)
+ postgresql_autodoc -d $(DBNAME) -f $(DOCDIR)/swh-scheduler
cp -a $(DOCDIR)/swh-scheduler.dot $(DOCDIR)/swh-scheduler.dot.orig
+ifndef PIFPAF
touch $@
+else
+ rm -f $@
+endif
-$(DOCDIR)/swh-scheduler.pdf: autodoc-stamp
- dot -T pdf $(DOCDIR)/swh-scheduler.dot > $(DOCDIR)/swh-scheduler.pdf
+$(DOCDIR)/swh-scheduler.pdf: $(DOCDIR)/swh-scheduler.dot autodoc-stamp
+ dot -T pdf $< > $@
+$(DOCDIR)/swh-scheduler.svg: $(DOCDIR)/swh-scheduler.dot autodoc-stamp
+ dot -T svg $< > $@
clean:
rm -rf *-stamp $(DOCDIR)/
diff --git a/sql/swh-scheduler-testdata.sql b/sql/swh-scheduler-testdata.sql
deleted file mode 100644
--- a/sql/swh-scheduler-testdata.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-begin;
-
-insert into task_type
- (type, backend_name, description, min_interval, max_interval, default_interval, backoff_factor)
-values
- ('git-updater', 'swh.loader.git.tasks.UpdateGitRepository', 'Git repository updater', '12 hours'::interval, '30 days'::interval, '1 day'::interval, 2);
-
-
-select swh_scheduler_mktemp_task ();
-
-
-insert into tmp_task
- (type, arguments, next_run)
-values
- ('git-updater',
- '{"args":["git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"], "kwargs":{}}'::jsonb,
- now());
-
-select * from swh_scheduler_create_tasks_from_temp ();
-
-commit;
-
-
-select * from swh_scheduler_grab_ready_tasks ();
-select * from swh_scheduler_schedule_task_run(1, 'foo');
-select * from swh_scheduler_start_task_run('foo', '{"worker": "worker01"}');
-select * from swh_scheduler_end_task_run('foo', true, '{"logs": "foobarbaz"}');
-
-select * from task;
-select * from task_run;
diff --git a/sql/updater/sql/Makefile b/sql/updater/sql/Makefile
--- a/sql/updater/sql/Makefile
+++ b/sql/updater/sql/Makefile
@@ -3,43 +3,66 @@
DBNAME = softwareheritage-scheduler-updater-dev
DOCDIR = autodoc
-SQL_INIT = swh-init.sql
-SQL_SCHEMA = swh-schema.sql
-SQL_FUNC = swh-func.sql
+SQL_INIT = 10-swh-init.sql
+SQL_SCHEMA = 30-swh-schema.sql
+SQL_FUNC = 40-swh-func.sql
SQLS = $(SQL_INIT) $(SQL_SCHEMA) $(SQL_FUNC)
+SQL_FILES = $(abspath $(addprefix \
+ $(CURDIR)/../../../swh/scheduler/sql/updater/,$(SQLS)))
PSQL_BIN = psql
PSQL_FLAGS = --echo-all -X -v ON_ERROR_STOP=1
PSQL = $(PSQL_BIN) $(PSQL_FLAGS)
+PIFPAF=$(findstring postgresql://,$(PIFPAF_URLS))
+
all:
createdb: createdb-stamp
-createdb-stamp: $(SQL_INIT)
+createdb-stamp: $(SQL_FILES)
+ifndef PIFPAF
+ -dropdb $(DBNAME)
+endif
createdb $(DBNAME)
+ifndef PIFPAF
touch $@
+else
+ rm -f $@
+endif
filldb: filldb-stamp
filldb-stamp: createdb-stamp
- cat $(SQLS) | $(PSQL) $(DBNAME)
+ cat $(SQL_FILES) | $(PSQL) $(DBNAME)
+ifndef PIFPAF
touch $@
+else
+ rm -f $@
+endif
dropdb:
-dropdb $(DBNAME)
dumpdb: swh-scheduler-updater.dump
-swh-scheduler.dump: filldb-stamp
+swh-scheduler-updater.dump: filldb-stamp
pg_dump -Fc $(DBNAME) > $@
-doc: autodoc-stamp $(DOCDIR)/swh-scheduler-updater.pdf
-autodoc-stamp: filldb-stamp
+$(DOCDIR):
test -d $(DOCDIR)/ || mkdir $(DOCDIR)
- postgresql_autodoc -d $(DBNAME) -f $(DOCDIR)/swh
- cp -a $(DOCDIR)/swh-scheduler.dot $(DOCDIR)/swh-scheduler-updater.dot.orig
+
+doc: autodoc-stamp $(DOCDIR)/swh-scheduler-updater.pdf
+autodoc-stamp: filldb-stamp $(DOCDIR)
+ postgresql_autodoc -d $(DBNAME) -f $(DOCDIR)/swh-scheduler-updater
+ cp -a $(DOCDIR)/swh-scheduler-updater.dot $(DOCDIR)/swh-scheduler-updater.dot.orig
+ifndef PIFPAF
touch $@
+else
+ rm -f $@
+endif
-$(DOCDIR)/swh-scheduler.pdf: autodoc-stamp
- dot -T pdf $(DOCDIR)/swh-scheduler-updater.dot > $(DOCDIR)/swh-scheduler-updater.pdf
+$(DOCDIR)/swh-scheduler-updater.pdf: $(DOCDIR)/swh-scheduler-updater.dot autodoc-stamp
+ dot -T pdf $< > $@
+$(DOCDIR)/swh-scheduler-updater.svg: $(DOCDIR)/swh-scheduler-updater.dot autodoc-stamp
+ dot -T svg $< > $@
clean:
rm -rf *-stamp $(DOCDIR)/
diff --git a/sql/swh-scheduler-schema.sql b/swh/scheduler/sql/30-swh-schema.sql
rename from sql/swh-scheduler-schema.sql
rename to swh/scheduler/sql/30-swh-schema.sql
diff --git a/sql/swh-scheduler-data.sql b/swh/scheduler/sql/40-swh-data.sql
rename from sql/swh-scheduler-data.sql
rename to swh/scheduler/sql/40-swh-data.sql
diff --git a/sql/updater/sql/swh-init.sql b/swh/scheduler/sql/updater/10-swh-init.sql
rename from sql/updater/sql/swh-init.sql
rename to swh/scheduler/sql/updater/10-swh-init.sql
diff --git a/sql/updater/sql/swh-schema.sql b/swh/scheduler/sql/updater/30-swh-schema.sql
rename from sql/updater/sql/swh-schema.sql
rename to swh/scheduler/sql/updater/30-swh-schema.sql
diff --git a/sql/updater/sql/swh-func.sql b/swh/scheduler/sql/updater/40-swh-func.sql
rename from sql/updater/sql/swh-func.sql
rename to swh/scheduler/sql/updater/40-swh-func.sql
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 3 2025, 6:09 PM (5 w, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220066
Attached To
D541: move sql files in the python package qand update tests according to D538
Event Timeline
Log In to Comment