Skip to content

Commit ca95bab

Browse files
committed
Merge branch 'measurements' of https://github.com/UW-Macrostrat/macrostrat into measurements
2 parents aa52154 + d21a2e7 commit ca95bab

File tree

25 files changed

+414
-27
lines changed

25 files changed

+414
-27
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build usage-stats
2+
on:
3+
push:
4+
# Branches and paths are exclusive
5+
branches: ["main"]
6+
paths:
7+
- services/usage-stats/**
8+
tags:
9+
- usage-stats-v[0-9]+.[0-9]+.[0-9]+ # Semver Release (non-prerelease)
10+
- usage-stats-v[0-9]+.[0-9]+.[0-9]+-** # Semver release (prerelease)
11+
pull_request:
12+
branches: [main]
13+
paths:
14+
- services/usage-stats/**
15+
jobs:
16+
docker:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
submodules: "recursive"
23+
# Set up python and poetry
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: 3.11
28+
- name: Install Poetry
29+
run: python3 -m pip install poetry==2.1.1
30+
- name: Build and stage local packages
31+
run: scripts/prepare-services
32+
- name: Get the version from the tag, if it exists
33+
run: |
34+
TAG=${{ github.event.release.tag_name }}
35+
VERSION=$(echo "${TAG}" | sed -E 's/usage-stats-v//')
36+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
37+
- name: Docker meta
38+
id: meta
39+
uses: docker/metadata-action@v4
40+
with:
41+
images: hub.opensciencegrid.org/macrostrat/usage-stats
42+
tags: |
43+
type=ref,event=pr,suffix=-{{date 'YYYYMMDDHHmmss'}}
44+
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
45+
type=semver,pattern={{version}}
46+
type=raw,value=latest,enable={{is_default_branch}}
47+
type=raw,value=sha-{{sha}}
48+
- name: Set up Docker BuildX
49+
uses: docker/setup-buildx-action@v2
50+
- name: Login to OSG DockerHub
51+
uses: docker/login-action@v2
52+
with:
53+
registry: hub.opensciencegrid.org
54+
username: ${{ vars.HARBOR_CLI_NAME }}
55+
password: ${{ secrets.HARBOR_CLI_SECRET }}
56+
- name: Build and push
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: services/usage-stats
60+
push: true
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max

.idea/dataSources.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sqldialects.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 48 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/macrostrat/cli/database/migrations/column_builder/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ class ColumnBuilderMigration(Migration):
1212
depends_on = ["macrostrat-core-v2"]
1313

1414
postconditions = [schema_exists("macrostrat_api")]
15+
16+
always_apply = True

cli/macrostrat/cli/database/migrations/map_sources/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class MapsSourcesMetadataMigration(Migration):
88
Create views for sources_metadata and ingest_process in the maps and macrostrat_api schemas
99
"""
1010

11-
depends_on = ["api-v3", "column-builder"]
11+
depends_on = ["api-v3"]
1212

1313
postconditions = [
1414
view_exists("maps", "sources_metadata", "ingest_process"),
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- SCHEMA
2+
CREATE SCHEMA IF NOT EXISTS ecosystem;
3+
4+
-- PEOPLE
5+
CREATE TABLE IF NOT EXISTS ecosystem.people (
6+
id serial PRIMARY KEY,
7+
name text NOT NULL,
8+
email text NOT NULL UNIQUE,
9+
title text NOT NULL,
10+
website text,
11+
img_id text,
12+
active_start timestamp with time zone NOT NULL DEFAULT now(),
13+
active_end timestamp with time zone
14+
);
15+
16+
-- ROLES
17+
CREATE TABLE IF NOT EXISTS ecosystem.roles (
18+
id serial PRIMARY KEY,
19+
name text NOT NULL UNIQUE,
20+
description text NOT NULL
21+
);
22+
23+
-- PEOPLE-ROLES MAPPING
24+
CREATE TABLE IF NOT EXISTS ecosystem.people_roles (
25+
person_id integer NOT NULL REFERENCES ecosystem.people(id) ON DELETE CASCADE,
26+
role_id integer NOT NULL REFERENCES ecosystem.roles(id) ON DELETE CASCADE,
27+
PRIMARY KEY (person_id, role_id)
28+
);
29+
30+
-- CONTRIBUTIONS
31+
CREATE TABLE IF NOT EXISTS ecosystem.contributions (
32+
id serial PRIMARY KEY,
33+
person_id integer NOT NULL REFERENCES ecosystem.people(id) ON DELETE CASCADE,
34+
contribution text NOT NULL,
35+
description text,
36+
date timestamp with time zone NOT NULL DEFAULT now(),
37+
url text
38+
);
39+
40+
-- PEOPLE-CONTRIBUTIONS MAPPING
41+
CREATE TABLE IF NOT EXISTS ecosystem.people_contributions (
42+
person_id integer NOT NULL REFERENCES ecosystem.people(id) ON DELETE CASCADE,
43+
contribution_id integer NOT NULL REFERENCES ecosystem.contributions(id) ON DELETE CASCADE,
44+
PRIMARY KEY (person_id, contribution_id)
45+
);
46+
47+
-- PREPOPULATE ROLES
48+
INSERT INTO ecosystem.roles (name, description) VALUES
49+
('Student', 'Currently enrolled in an academic program'),
50+
('Researcher', 'Conducts academic or applied research'),
51+
('Developer', 'Writes and maintains software code'),
52+
('Leader', 'Leads research or development projects and mentors others'),
53+
('Collaborator', 'Contributes to joint projects'),
54+
ON CONFLICT (name) DO NOTHING;

cli/macrostrat/cli/database/migrations/update_macrostrat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ class MacrostratCoreMigration(Migration):
1818

1919
postconditions = [
2020
exists("macrostrat", "units", "sections"),
21-
has_fks("macrostrat", "units", "sections"),
21+
has_fks("macrostrat", "units", "sections", "strat_names"),
2222
]

cli/macrostrat/cli/entrypoint.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@ def inspect():
380380
IPython.embed()
381381

382382

383+
# Print the environment variables
384+
@self_app.command()
385+
def printenv():
386+
"""Print the environment variables"""
387+
for k, v in environ.items():
388+
print(f"[bold cyan]{k}[/]: {v}")
389+
390+
383391
main.add_typer(
384392
self_app,
385393
name="self",

cli/macrostrat/cli/subsystems/sgp/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from typer import Typer
66

7+
from macrostrat.cli.database import get_db
8+
79
from .match import import_sgp_data, log_matches
10+
from .migrations import *
811
from .paleogeography import compute_paleo_positions
912

1013
sgp = Typer(
@@ -15,3 +18,17 @@
1518
sgp.command(name="match-units")(import_sgp_data)
1619
sgp.command(name="paleogeography")(compute_paleo_positions)
1720
sgp.command(name="log-matches")(log_matches)
21+
22+
23+
@sgp.command("import-data")
24+
def import_sgp_data():
25+
"""
26+
Import SGP sample and analysis data.
27+
"""
28+
29+
db = get_db()
30+
31+
sql_dir = Path(__file__).parent / "sql"
32+
33+
db.run_sql(sql_dir / "create-fdw.sql")
34+
db.run_sql(sql_dir / "copy-sgp-data.sql")

0 commit comments

Comments
 (0)