Skip to content

Commit c0fa30a

Browse files
authored
skip WaveformArray.java, add fake array inserts (#41)
* skip WaveformArray.java, add fake array inserts * bump lint * fix typo and bump versions * another typo * unpin superlinter * superlinter * bump more versions * bump minimum version of python
1 parent f43d884 commit c0fa30a

File tree

12 files changed

+51
-41
lines changed

12 files changed

+51
-41
lines changed

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: Checkout code
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v6
3737
with:
3838
# Full git history is needed to get a proper list of
3939
# changed files within `super-linter`
4040
fetch-depth: 0
4141
persist-credentials: false
4242

4343
- name: Setup Python
44-
uses: actions/setup-python@v3
44+
uses: actions/setup-python@v6
4545

4646
- name: Run pre-commit
47-
uses: pre-commit/action@v3.0.0
47+
uses: pre-commit/action@v3.0.1
4848
with:
4949
extra_args: --all-files
5050

5151
- name: Lint code base
52-
uses: github/super-linter/slim@v4.9.7
52+
uses: super-linter/super-linter/slim@v8
5353
env:
5454
VALIDATE_ALL_CODEBASE: false
5555
DEFAULT_BRANCH: main

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout code
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v6
3434

3535
- name: Install Python
36-
uses: actions/setup-python@v3
36+
uses: actions/setup-python@v6
3737

3838
- name: Install Python dependencies
3939
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ satellite.egg-info/
66
.mypy_cache/
77
.pytest_cache/
88
.DS_Store
9+
.vscode
10+
tmp*

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ fail_fast: true
1616

1717
repos:
1818
- repo: https://github.com/ambv/black
19-
rev: 22.12.0
19+
rev: 26.1.0
2020
hooks:
2121
- id: black
2222
args: [--diff, --check]
2323

2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v0.991
25+
rev: v1.19.1
2626
hooks:
2727
- id: mypy
2828
args: [--ignore-missing-imports]
2929

3030
- repo: https://github.com/pycqa/flake8
31-
rev: 6.1.0
31+
rev: 7.3.0
3232
hooks:
3333
- id: flake8
3434

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
FROM postgres:15.0-bullseye
14+
FROM postgres:17
1515

1616
# User definable arguments
1717
ARG POSTGRES_USER=postgres
@@ -32,7 +32,7 @@ ARG DEBIAN_FRONTEND=noninteractive
3232
# OS setup
3333
RUN apt-get update && \
3434
apt-get install --yes --no-install-recommends \
35-
procps ca-certificates locales python3.9-dev python3-pip git && \
35+
procps ca-certificates locales pipx git && \
3636
apt-get clean && \
3737
rm -rf /var/lib/apt/lists/* && \
3838
sed -i '/en_GB.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
@@ -46,11 +46,11 @@ RUN if [ -d "/Satellite/satellite" ] ; then \
4646
echo "Cloning Satellite repo on: $TAG" && \
4747
rm -rf /Satellite && \
4848
git clone --depth 1 --branch ${TAG} https://github.com/SAFEHR-data/Satellite.git ;\
49-
fi && \
50-
pip install --no-cache-dir --upgrade pip==22.3.1
49+
fi
5150

51+
ENV PATH="$PATH:/root/.local/bin"
5252
WORKDIR /Satellite
53-
RUN pip install --no-cache-dir . && \
53+
RUN pipx install . && \
5454
satellite print-db-create-command > /docker-entrypoint-initdb.d/create.sql && \
5555
satellite print-create-command >> /docker-entrypoint-initdb.d/create.sql
5656

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "satellite"
3-
version = "0.1.2"
3+
version = "0.2.0"
44
authors = [
55
{ name="Tom Young" },
66
]
77
description = "Create, update and delete rows in a synthetic EMAP star schema"
88
readme = "README.md"
9-
requires-python = ">=3.9"
9+
requires-python = ">=3.10"
1010
license = {file = "LICENSE"}
1111
classifiers = [
1212
"Programming Language :: Python :: 3"
@@ -17,7 +17,7 @@ dependencies = [
1717
"coloredlogs==15.0.*",
1818
"networkx==2.8.*",
1919
"click==8.1.*",
20-
"black==22.12.*",
20+
"black==26.1.*",
2121
"psycopg2-binary==2.9.*",
2222
"pytest==7.2.*"
2323
]

satellite/_column.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import Optional, Callable, TYPE_CHECKING
14+
from typing import Optional, Callable, Any, TYPE_CHECKING
1515
from dataclasses import dataclass
1616

1717
from satellite._log import logger
1818
from satellite._fake import fake
1919

20-
2120
if TYPE_CHECKING:
2221
from satellite._tables import Table
2322

@@ -54,6 +53,7 @@ def sql_type(self) -> str:
5453
"double": "real",
5554
"localdate": "date",
5655
"byte[]": "bytea",
56+
"double[]": "real[]",
5757
}
5858

5959
if self.java_type.lower() in java_to_sql_type_map:
@@ -65,16 +65,17 @@ def sql_type(self) -> str:
6565
)
6666
return "text"
6767

68-
@property
69-
def format_specifier(self) -> str:
68+
def sql_marshal(self, value: Any) -> str:
7069
if self.sql_type == "text":
71-
return "'%s'"
70+
return f"'{value}'"
7271
elif self.sql_type == "timestamptz" or self.sql_type == "date":
73-
return "timestamp '%s'"
72+
return f"timestamp '{value}'"
7473
elif self.sql_type == "bytea":
75-
return "E'%s'"
74+
return f"E'{value}'"
75+
elif self.sql_type == "real[]":
76+
return f"ARRAY {str(value)}"
7677

77-
return "%s"
78+
return str(value)
7879

7980
@property
8081
def is_foreign_key(self) -> bool:
@@ -114,5 +115,5 @@ def faker_method(self) -> Callable:
114115
return getattr(fake, self.sql_type)
115116

116117
else:
117-
logger.error(f"Have no provider for {self.sql_type}")
118+
logger.error(f"Have no provider for {self.sql_type} in column {self.name}")
118119
return fake.default

satellite/_fake.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def standardised_code() -> None:
128128
def standardised_vocabulary() -> None:
129129
return None
130130

131+
def values_array(self) -> list[float]:
132+
return [self.real() for _ in range(10)]
133+
131134

132135
class _StarPersonProvider(PersonProvider, _StarBaseProvider):
133136
def firstname(self) -> str:

satellite/_schema.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ def _try_and_connect(self) -> None:
8989

9090
def empty_table_create_command_for(self, table: Table) -> str:
9191
"""Create a table for a set of data. Drop it if it exists"""
92-
93-
columns_name_and_type = ", ".join(
94-
[col.definition_in_schema(self._name) for col in table.non_pk_columns]
95-
)
92+
non_pk_columns = ""
93+
if len(table.non_pk_columns) > 0:
94+
non_pk_columns += ", " + ", ".join(
95+
[col.definition_in_schema(self._name) for col in table.non_pk_columns]
96+
)
9697
return (
97-
f"CREATE TABLE {self.schema_name}.{table.name} "
98-
f"({table.primary_key_name} serial PRIMARY KEY, "
99-
f"{columns_name_and_type});"
98+
f"CREATE TABLE {self.schema_name}.{table.name}"
99+
f"({table.primary_key_name} serial PRIMARY KEY{non_pk_columns});"
100100
)
101101

102102
@staticmethod
@@ -118,9 +118,11 @@ def add_data_command_for(self, table: Table) -> str:
118118

119119
for i in range(table.n_rows):
120120
values = ",".join(
121-
column.format_specifier % self._decode_if_bytes(table[column][i])
122-
if table[column][i] is not None
123-
else "null"
121+
(
122+
column.sql_marshal(self._decode_if_bytes(table[column][i]))
123+
if table[column][i] is not None
124+
else "null"
125+
)
124126
for column in table.non_pk_columns
125127
)
126128
string += f" ({values}),\n"

satellite/_settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from typing import Any
1717

18-
1918
_default_values = {
2019
"STAR_SCHEMA_NAME": "star",
2120
"FAKER_SEED": "0",

0 commit comments

Comments
 (0)