Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7474e0d
Add testing data
davenquinn Nov 14, 2025
5f73d07
Updated foreign data wrapper script
davenquinn Nov 14, 2025
a9e1ed3
Improve CLI loading so tests can be run from within the app
davenquinn Nov 14, 2025
b1fa2f1
Move SGP tests to a more central location
davenquinn Nov 14, 2025
d8ae437
Moved strat name cleaning code to match-utils
davenquinn Nov 14, 2025
f3712c6
Started to move towards monorepo
davenquinn Nov 14, 2025
394d737
Add CORS headers to backend responses
davenquinn Nov 14, 2025
f4dd634
Fixed SGP matching
davenquinn Nov 18, 2025
a12a97b
Updated Macrostrat match utils
davenquinn Nov 18, 2025
7d705e9
Added a function to get multiple matches
davenquinn Nov 18, 2025
f062810
Slight reorganization
davenquinn Nov 18, 2025
e51b267
Upgraded match utils and API dependencies
davenquinn Nov 18, 2025
e1b8b92
Fixed python env
davenquinn Nov 18, 2025
74077ca
Continued updates to match UI
davenquinn Nov 18, 2025
81cfdc3
Fixed missing import
davenquinn Nov 19, 2025
f830b8f
Updated testing framework and UV sync
davenquinn Nov 19, 2025
388a297
Updated basic match API
davenquinn Nov 19, 2025
ab211a0
Working API for single matches
davenquinn Nov 19, 2025
6057db3
Matching multiple units works
davenquinn Nov 19, 2025
0433e2b
added test fro cli
davenquinn Nov 20, 2025
96167cb
Updated app to have an --env option
davenquinn Nov 20, 2025
ac544ee
Upgraded match utils
davenquinn Nov 20, 2025
d67762a
Added examples and body size limiting
davenquinn Nov 20, 2025
bd21e64
Start to deal with time windows
davenquinn Nov 21, 2025
79e470a
All matching tests pass
davenquinn Nov 21, 2025
580f5ad
All passed
davenquinn Nov 21, 2025
4db8e9d
Don't duplicate matches
davenquinn Nov 21, 2025
4750a49
Updated min_age and max_age -> t_age and b_age
davenquinn Nov 21, 2025
04899a3
Updated dependencies
davenquinn Nov 21, 2025
92aa89c
Updated match UI
davenquinn Nov 21, 2025
89e077b
Updated match api container
davenquinn Nov 21, 2025
f87ab3d
Updated uv lock file
davenquinn Nov 21, 2025
13a2c36
Format code and sort imports
davenquinn Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.venv
__pycache__
macrostrat.toml
macrostrat.toml
*.egg-info
*.pyc
1 change: 1 addition & 0 deletions .idea/data_source_mapping.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions .idea/macrostrat.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Setting the `MACROSTRAT_PYROOT` environment variable allows a different root
Python version to be installed. This can be used to add new plugins
or application dependencies.

### Debugging the installation

- Run `macrostrat uv sync` to ensure that all dependencies are installed.

## Usage

Once a Macrostrat configuration file is defined, the Macrostrat command-line app
Expand Down
2 changes: 1 addition & 1 deletion bin/macrostrat
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if [ "$1" = "uv" ]; then
echo -e "MACROSTRAT_PYROOT is set to \033[36m$BASE_DIR\033[0m"
echo ""
fi
$_uv --directory "$BASE_DIR" "$@"
$_uv --project "$BASE_DIR" "$@"
exit $?
fi

Expand Down
2 changes: 0 additions & 2 deletions cli/macrostrat/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
__version__ = "2.0.0"

from .entrypoint import main
2 changes: 1 addition & 1 deletion cli/macrostrat/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import main
from .entrypoint import main

main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

ALTER TABLE macrostrat.projects ADD COLUMN IF NOT EXISTS is_composite BOOLEAN DEFAULT FALSE;


CREATE TABLE IF NOT EXISTS macrostrat.project_composite (
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
parent_project_id integer REFERENCES macrostrat.projects(id) ON DELETE CASCADE,
child_project_id integer REFERENCES macrostrat.projects(id) ON DELETE CASCADE,
UNIQUE (parent_project_id, child_project_id)
);

-- Ensure that only composite projects can be parent of other projects
CREATE OR REPLACE FUNCTION macrostrat.check_composite_parent()
RETURNS TRIGGER AS $$
BEGIN
IF NOT (SELECT is_composite FROM macrostrat.projects WHERE id = NEW.parent_project_id) THEN
RAISE EXCEPTION 'Parent project must be a composite project';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Create the trigger on the project_composite table
CREATE TRIGGER trg_check_composite_parent
BEFORE INSERT OR UPDATE ON macrostrat.project_composite
FOR EACH ROW EXECUTE FUNCTION macrostrat.check_composite_parent();

/**
Ensure that only non-composite projects can have columns as children.
This is probably not strictly necessary, but it makes the composite project
system a bit more straightforward at the start.
*/
CREATE OR REPLACE FUNCTION macrostrat.check_column_project_non_composite()
RETURNS TRIGGER AS $$
BEGIN
IF (SELECT is_composite FROM macrostrat.projects WHERE id = NEW.project_id)
THEN
RAISE EXCEPTION 'A composite project cannot itself contain columns. We may relax this restriction in the future.';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Add the trigger on the macrostrat.cols table
CREATE TRIGGER trg_check_column_project_non_composite
BEFORE INSERT OR UPDATE ON macrostrat.cols
FOR EACH ROW EXECUTE FUNCTION macrostrat.check_column_project_non_composite();


/** Take the opportunity to add a slug for nicer URLs **/
ALTER TABLE macrostrat.projects ADD COLUMN IF NOT EXISTS slug TEXT UNIQUE;

/** Function to generate slugs from project names **/
CREATE OR REPLACE FUNCTION macrostrat.generate_project_slug()
RETURNS VOID AS $$
DECLARE
proj RECORD;
base_slug TEXT;
unique_slug TEXT;
suffix INT;
BEGIN
FOR proj IN SELECT id, name FROM macrostrat.projects WHERE slug IS NULL LOOP
base_slug := lower(regexp_replace(proj.name, '[^a-zA-Z0-9]+', '-', 'g'));
unique_slug := base_slug;
suffix := 1;
WHILE EXISTS (SELECT 1 FROM macrostrat.projects WHERE slug = unique_slug) LOOP
suffix := suffix + 1;
unique_slug := base_slug || '-' || suffix;
END LOOP;
UPDATE macrostrat.projects SET slug = unique_slug WHERE id = proj.id;
END LOOP;
END;
$$ LANGUAGE plpgsql;
3 changes: 2 additions & 1 deletion cli/macrostrat/cli/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ def update_weaver(db):
main.add_typer(
mariadb_app,
name="mariadb",
rich_help_panel="Subsystems",
rich_help_panel="Legacy",
short_help="Manage the MariaDB database",
deprecated=True,
)

# Knowledge graph CLI
Expand Down
11 changes: 9 additions & 2 deletions cli/macrostrat/cli/subsystems/sgp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ def import_sgp_data():
print("Importing SGP data...")
print(sgp_db.engine.url)

host = sgp_db.engine.url.host
port = sgp_db.engine.url.port or 5432

if host == "localhost":
# Use an internal port for connectivity.
port = "5432"

db.run_sql(
sql_dir / "create-fdw.sql",
dict(
sgp_host=sgp_db.engine.url.host,
sgp_port=str(sgp_db.engine.url.port or 5432),
sgp_host=host,
sgp_port=str(port),
sgp_database=sgp_db.engine.url.database,
sgp_user=sgp_db.engine.url.username,
sgp_password=sgp_db.engine.url.password,
Expand Down
Loading