Skip to content

Commit 22e8404

Browse files
committed
Chore: Implement suggestions by CodeRabbit (periodic tasks)
1 parent 9fbed5a commit 22e8404

19 files changed

Lines changed: 32 additions & 35 deletions

operation/periodic-task/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ python {cron.py,worker.py}
5454
```
5555

5656

57-
[Apache Airflow]: https://airflow.apache.org/
57+
[Airflow]: https://airflow.apache.org/
5858
[APScheduler]: https://pypi.org/project/APScheduler/
5959
[cron]: https://en.wikipedia.org/wiki/Cron
6060
[crontab guru]: https://crontab.guru/

operation/periodic-task/airflow/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ Navigate to http://localhost:8080/.
3030

3131
If your DAGs don't start running, check for any hard errors.
3232
```shell
33-
docker exec -it airflow-scheduler-1 sh -c 'airflow dags list-import-errors'
33+
docker compose exec scheduler sh -c 'airflow dags list-import-errors'
3434
```
3535

3636
List available DAGs.
3737
```shell
38-
docker exec -it airflow-scheduler-1 sh -c 'airflow dags list'
38+
docker compose exec scheduler sh -c 'airflow dags list'
3939
```
4040

4141
List runs of specific DAG.
4242
```shell
43-
docker exec -it airflow-scheduler-1 sh -c 'airflow dags list-runs sys_summits'
44-
docker exec -it airflow-scheduler-1 sh -c 'airflow dags list-runs import_export'
43+
docker compose exec scheduler sh -c 'airflow dags list-runs sys_summits'
44+
docker compose exec scheduler sh -c 'airflow dags list-runs import_export'
4545
```
4646

4747
Invoke DAG workflow manually.
4848
```shell
49-
docker exec -it airflow-scheduler-1 sh -c 'airflow dags trigger import_export'
49+
docker compose exec scheduler sh -c 'airflow dags trigger import_export'
5050
```
5151

5252
Check state of DAG.
5353
```shell
54-
docker exec -it airflow-scheduler-1 sh -c 'airflow tasks state export_job export_to_s3 scheduled__2021-11-11T00:00:11+00:00'
54+
docker compose exec scheduler sh -c 'airflow tasks state export_job export_to_s3 scheduled__2021-11-11T00:00:11+00:00'
5555
```
5656

5757

operation/periodic-task/airflow/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22

33
# CrateDB database.
44
cratedb:
5-
image: docker.io/crate/crate:${CRATEDB_VERSION:-latest}
5+
image: docker.io/crate:${CRATEDB_VERSION:-latest}
66
command: >
77
crate
88
'-Cdiscovery.type=single-node'

operation/periodic-task/airflow/workflows.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
dag_id="sys_summits",
2828
description="Example DAG for plain-text SQL task.",
2929
default_args={"conn_id": "cratedb_connection"},
30-
schedule="*/10 * * * * * *", # @continuous, @daily
30+
schedule="*/1 * * * *", # @continuous, @daily
3131
catchup=False,
3232
max_active_runs=1,
3333
):
@@ -44,7 +44,7 @@ def execute_query_taskflow():
4444
dag_id="import_export",
4545
description="Example DAG for SQLExecuteQueryOperator",
4646
default_args={"conn_id": "cratedb_connection"},
47-
schedule="*/30 * * * * * *", # @continuous, @daily
47+
schedule="*/5 * * * *", # @continuous, @daily
4848
catchup=False,
4949
max_active_runs=1,
5050
):
@@ -61,7 +61,7 @@ def execute_query_taskflow():
6161
}
6262

6363
ddl = SQLExecuteQueryOperator(
64-
task_id=f"submit_ddl",
64+
task_id="submit_ddl",
6565
conn_id="cratedb_connection",
6666
sql="""
6767
CREATE TABLE IF NOT EXISTS {{params.table}} (
@@ -76,7 +76,7 @@ def execute_query_taskflow():
7676
)
7777

7878
insert = SQLExecuteQueryOperator(
79-
task_id=f"import_from_http",
79+
task_id="import_from_http",
8080
conn_id="cratedb_connection",
8181
sql="""
8282
COPY {{params.table}}
@@ -88,7 +88,7 @@ def execute_query_taskflow():
8888
)
8989

9090
export = SQLExecuteQueryOperator(
91-
task_id=f"export_to_s3",
91+
task_id="export_to_s3",
9292
conn_id="cratedb_connection",
9393
sql="""
9494
COPY {{params.table}}
@@ -114,7 +114,7 @@ def execute_query_taskflow():
114114
dag_id="export_deltalake",
115115
description="Example DAG for CrateDB Toolkit I/O",
116116
default_args={"conn_id": "cratedb_connection"},
117-
schedule="*/30 * * * * * *", # @continuous, @daily
117+
schedule="*/5 * * * *", # @continuous, @daily
118118
catchup=False,
119119
max_active_runs=1,
120120
):

operation/periodic-task/plombery/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ COPY requirements.txt .
1717
RUN --mount=type=cache,id=uv-${TARGETARCH}${TARGETVARIANT},target=/root/.cache/uv \
1818
uv pip install --requirements=requirements.txt
1919

20-
# Add programs to be scheduled periodically to the `dags` folder.
21-
# Their schedule is defined inline with the program source.
20+
# Add the workflow program to be scheduled periodically.
2221
COPY workflow.py .
2322
CMD ["python", "workflow.py"]

operation/periodic-task/plombery/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22

33
cratedb:
4-
image: docker.io/crate/crate:${CRATEDB_VERSION:-latest}
4+
image: docker.io/crate:${CRATEDB_VERSION:-latest}
55
command: >
66
crate
77
'-Cdiscovery.type=single-node'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
plombery
2-
sqlalchemy-cratedb
1+
plombery>=0.4.0,<1.0
2+
sqlalchemy-cratedb>=0.40.0,<1.0

operation/periodic-task/prefect/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ COPY requirements.txt .
1717
RUN --mount=type=cache,id=uv-${TARGETARCH}${TARGETVARIANT},target=/root/.cache/uv \
1818
uv pip install --requirements=requirements.txt
1919

20-
# Add programs to be scheduled periodically to the `dags` folder.
21-
# Their schedule is defined inline with the program source.
20+
# Add the workflow program to be scheduled periodically.
2221
COPY workflow.py .
2322
CMD ["python", "workflow.py"]

operation/periodic-task/prefect/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22

33
cratedb:
4-
image: docker.io/crate/crate:${CRATEDB_VERSION:-latest}
4+
image: docker.io/crate:${CRATEDB_VERSION:-latest}
55
command: >
66
crate
77
'-Cdiscovery.type=single-node'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
prefect
2-
sqlalchemy-cratedb
1+
prefect>=3.0.0,<4.0
2+
sqlalchemy-cratedb>=0.40.0,<1.0

0 commit comments

Comments
 (0)