dbos 1.12.0a2__py3-none-any.whl → 1.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dbos might be problematic. Click here for more details.
- dbos/_alembic_migrations/versions/471b60d64126_dbos_migrations.py +35 -0
- dbos/_app_db.py +215 -80
- dbos/_client.py +30 -15
- dbos/_context.py +4 -0
- dbos/_core.py +7 -8
- dbos/_dbos.py +28 -18
- dbos/_dbos_config.py +124 -50
- dbos/_fastapi.py +3 -1
- dbos/_logger.py +3 -1
- dbos/_migration.py +322 -0
- dbos/_sys_db.py +122 -200
- dbos/_sys_db_postgres.py +173 -0
- dbos/_sys_db_sqlite.py +182 -0
- dbos/_tracer.py +5 -1
- dbos/_utils.py +10 -1
- dbos/cli/cli.py +238 -100
- dbos/cli/migration.py +2 -2
- dbos/dbos-config.schema.json +4 -0
- {dbos-1.12.0a2.dist-info → dbos-1.13.0.dist-info}/METADATA +1 -1
- dbos-1.13.0.dist-info/RECORD +78 -0
- dbos-1.12.0a2.dist-info/RECORD +0 -74
- /dbos/{_migrations → _alembic_migrations}/env.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/script.py.mako +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/01ce9f07bd10_streaming.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/04ca4f231047_workflow_queues_executor_id.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/27ac6900c6ad_add_queue_dedup.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/50f3227f0b4b_fix_job_queue.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/5c361fc04708_added_system_tables.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/66478e1b95e5_consolidate_queues.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/83f3732ae8e7_workflow_timeout.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/933e86bdac6a_add_queue_priority.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/a3b18ad34abe_added_triggers.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/d76646551a6b_job_queue_limiter.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/d76646551a6c_workflow_queue.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/d994145b47b6_consolidate_inputs.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/eab0cc1d9a14_job_queue.py +0 -0
- /dbos/{_migrations → _alembic_migrations}/versions/f4b9b32ba814_functionname_childid_op_outputs.py +0 -0
- {dbos-1.12.0a2.dist-info → dbos-1.13.0.dist-info}/WHEEL +0 -0
- {dbos-1.12.0a2.dist-info → dbos-1.13.0.dist-info}/entry_points.txt +0 -0
- {dbos-1.12.0a2.dist-info → dbos-1.13.0.dist-info}/licenses/LICENSE +0 -0
dbos/cli/cli.py
CHANGED
|
@@ -5,7 +5,7 @@ import subprocess
|
|
|
5
5
|
import time
|
|
6
6
|
import typing
|
|
7
7
|
from os import path
|
|
8
|
-
from typing import Any, Optional
|
|
8
|
+
from typing import Any, Optional, Tuple
|
|
9
9
|
|
|
10
10
|
import jsonpickle # type: ignore
|
|
11
11
|
import sqlalchemy as sa
|
|
@@ -14,65 +14,69 @@ from rich import print as richprint
|
|
|
14
14
|
from rich.prompt import IntPrompt
|
|
15
15
|
from typing_extensions import Annotated, List
|
|
16
16
|
|
|
17
|
+
from dbos._context import SetWorkflowID
|
|
17
18
|
from dbos._debug import debug_workflow, parse_start_command
|
|
18
19
|
from dbos.cli.migration import grant_dbos_schema_permissions, migrate_dbos_databases
|
|
19
20
|
|
|
20
|
-
from .._app_db import ApplicationDatabase
|
|
21
21
|
from .._client import DBOSClient
|
|
22
22
|
from .._dbos_config import (
|
|
23
|
+
ConfigFile,
|
|
23
24
|
_app_name_to_db_name,
|
|
24
25
|
_is_valid_app_name,
|
|
26
|
+
get_application_database_url,
|
|
25
27
|
get_system_database_url,
|
|
26
|
-
is_valid_database_url,
|
|
27
28
|
load_config,
|
|
28
29
|
)
|
|
29
30
|
from .._docker_pg_helper import start_docker_pg, stop_docker_pg
|
|
30
|
-
from ..
|
|
31
|
-
from .._sys_db import SystemDatabase, reset_system_database
|
|
31
|
+
from .._sys_db import SystemDatabase
|
|
32
32
|
from .._utils import GlobalParams
|
|
33
33
|
from ..cli._github_init import create_template_from_github
|
|
34
34
|
from ._template_init import copy_template, get_project_name, get_templates_directory
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def _get_db_url(
|
|
37
|
+
def _get_db_url(
|
|
38
|
+
*, system_database_url: Optional[str], application_database_url: Optional[str]
|
|
39
|
+
) -> Tuple[str, str]:
|
|
38
40
|
"""
|
|
39
41
|
Get the database URL to use for the DBOS application.
|
|
40
42
|
Order of precedence:
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
- If the `
|
|
43
|
+
- In DBOS Cloud, use the environment variables provided.
|
|
44
|
+
- Use database URL arguments if provided.
|
|
45
|
+
- If the `dbos-config.yaml` file is present, use the database URLs from it.
|
|
44
46
|
|
|
45
|
-
Otherwise fallback to the same
|
|
47
|
+
Otherwise fallback to the same SQLite Postgres URL than the DBOS library.
|
|
46
48
|
Note that for the latter to be possible, a configuration file must have been found, with an application name set.
|
|
47
49
|
"""
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
if os.environ.get("DBOS__CLOUD") == "true":
|
|
51
|
+
system_database_url = os.environ.get("DBOS_SYSTEM_DATABASE_URL")
|
|
52
|
+
application_database_url = os.environ.get("DBOS_DATABASE_URL")
|
|
53
|
+
assert system_database_url and application_database_url
|
|
54
|
+
return system_database_url, application_database_url
|
|
55
|
+
if system_database_url or application_database_url:
|
|
56
|
+
cfg: ConfigFile = {
|
|
57
|
+
"system_database_url": system_database_url,
|
|
58
|
+
"database_url": application_database_url,
|
|
59
|
+
}
|
|
60
|
+
return get_system_database_url(cfg), get_application_database_url(cfg)
|
|
61
|
+
else:
|
|
51
62
|
# Load from config file if present
|
|
52
63
|
try:
|
|
53
|
-
config = load_config(
|
|
54
|
-
database_url
|
|
55
|
-
|
|
64
|
+
config = load_config(silent=True)
|
|
65
|
+
if config.get("database_url") or config.get("system_database_url"):
|
|
66
|
+
return get_system_database_url(config), get_application_database_url(
|
|
67
|
+
config
|
|
68
|
+
)
|
|
69
|
+
else:
|
|
70
|
+
_app_db_name = _app_name_to_db_name(config["name"])
|
|
71
|
+
# Fallback on the same defaults than the DBOS library
|
|
72
|
+
default_url = f"sqlite:///{_app_db_name}.sqlite"
|
|
73
|
+
return default_url, default_url
|
|
56
74
|
except (FileNotFoundError, OSError):
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# Fallback on the same defaults than the DBOS library
|
|
63
|
-
_password = os.environ.get("PGPASSWORD", "dbos")
|
|
64
|
-
database_url = f"postgres://postgres:{_password}@localhost:5432/{_app_db_name}?connect_timeout=10&sslmode=prefer"
|
|
65
|
-
if database_url is None:
|
|
66
|
-
raise ValueError(
|
|
67
|
-
"Missing database URL: please set it using the --db-url flag, the DBOS_DATABASE_URL environment variable, or in your dbos-config.yaml file."
|
|
68
|
-
)
|
|
69
|
-
assert is_valid_database_url(database_url)
|
|
70
|
-
return database_url
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def start_client(db_url: Optional[str] = None) -> DBOSClient:
|
|
74
|
-
database_url = _get_db_url(db_url)
|
|
75
|
-
return DBOSClient(database_url=database_url)
|
|
75
|
+
typer.echo(
|
|
76
|
+
f"Error: Missing database URL: please set it using CLI flags or your dbos-config.yaml file.",
|
|
77
|
+
err=True,
|
|
78
|
+
)
|
|
79
|
+
raise typer.Exit(code=1)
|
|
76
80
|
|
|
77
81
|
|
|
78
82
|
app = typer.Typer()
|
|
@@ -114,7 +118,7 @@ def _on_windows() -> bool:
|
|
|
114
118
|
help="Start your DBOS application using the start commands in 'dbos-config.yaml'"
|
|
115
119
|
)
|
|
116
120
|
def start() -> None:
|
|
117
|
-
config = load_config(
|
|
121
|
+
config = load_config(silent=True)
|
|
118
122
|
start_commands = config["runtimeConfig"]["start"]
|
|
119
123
|
typer.echo("Executing start commands from 'dbos-config.yaml'")
|
|
120
124
|
for command in start_commands:
|
|
@@ -263,7 +267,7 @@ def _resolve_project_name_and_template(
|
|
|
263
267
|
|
|
264
268
|
@app.command(help="Create DBOS system tables.")
|
|
265
269
|
def migrate(
|
|
266
|
-
|
|
270
|
+
application_database_url: Annotated[
|
|
267
271
|
typing.Optional[str],
|
|
268
272
|
typer.Option(
|
|
269
273
|
"--db-url",
|
|
@@ -288,28 +292,25 @@ def migrate(
|
|
|
288
292
|
),
|
|
289
293
|
] = None,
|
|
290
294
|
) -> None:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
"system_database_url": system_database_url,
|
|
295
|
-
"database_url": app_database_url,
|
|
296
|
-
"database": {},
|
|
297
|
-
}
|
|
295
|
+
system_database_url, application_database_url = _get_db_url(
|
|
296
|
+
system_database_url=system_database_url,
|
|
297
|
+
application_database_url=application_database_url,
|
|
298
298
|
)
|
|
299
299
|
|
|
300
300
|
typer.echo(f"Starting DBOS migrations")
|
|
301
|
-
typer.echo(f"Application database: {sa.make_url(
|
|
301
|
+
typer.echo(f"Application database: {sa.make_url(application_database_url)}")
|
|
302
302
|
typer.echo(f"System database: {sa.make_url(system_database_url)}")
|
|
303
303
|
|
|
304
304
|
# First, run DBOS migrations on the system database and the application database
|
|
305
305
|
migrate_dbos_databases(
|
|
306
|
-
app_database_url=
|
|
306
|
+
app_database_url=application_database_url,
|
|
307
|
+
system_database_url=system_database_url,
|
|
307
308
|
)
|
|
308
309
|
|
|
309
310
|
# Next, assign permissions on the DBOS schema to the application role, if any
|
|
310
311
|
if application_role:
|
|
311
312
|
grant_dbos_schema_permissions(
|
|
312
|
-
database_url=
|
|
313
|
+
database_url=application_database_url, role_name=application_role
|
|
313
314
|
)
|
|
314
315
|
grant_dbos_schema_permissions(
|
|
315
316
|
database_url=system_database_url, role_name=application_role
|
|
@@ -317,7 +318,7 @@ def migrate(
|
|
|
317
318
|
|
|
318
319
|
# Next, run any custom migration commands specified in the configuration
|
|
319
320
|
if os.path.exists("dbos-config.yaml"):
|
|
320
|
-
config = load_config(
|
|
321
|
+
config = load_config(silent=True)
|
|
321
322
|
if "database" not in config:
|
|
322
323
|
config["database"] = {}
|
|
323
324
|
migrate_commands = (
|
|
@@ -345,20 +346,20 @@ def migrate(
|
|
|
345
346
|
@app.command(help="Reset the DBOS system database")
|
|
346
347
|
def reset(
|
|
347
348
|
yes: bool = typer.Option(False, "-y", "--yes", help="Skip confirmation prompt"),
|
|
348
|
-
|
|
349
|
+
application_database_url: Annotated[
|
|
349
350
|
typing.Optional[str],
|
|
350
351
|
typer.Option(
|
|
351
|
-
"--
|
|
352
|
-
"-
|
|
353
|
-
help="
|
|
352
|
+
"--db-url",
|
|
353
|
+
"-D",
|
|
354
|
+
help="Your DBOS application database URL",
|
|
354
355
|
),
|
|
355
356
|
] = None,
|
|
356
|
-
|
|
357
|
+
system_database_url: Annotated[
|
|
357
358
|
typing.Optional[str],
|
|
358
359
|
typer.Option(
|
|
359
|
-
"--db-url",
|
|
360
|
-
"-
|
|
361
|
-
help="Your DBOS
|
|
360
|
+
"--sys-db-url",
|
|
361
|
+
"-s",
|
|
362
|
+
help="Your DBOS system database URL",
|
|
362
363
|
),
|
|
363
364
|
] = None,
|
|
364
365
|
) -> None:
|
|
@@ -370,22 +371,12 @@ def reset(
|
|
|
370
371
|
typer.echo("Operation cancelled.")
|
|
371
372
|
raise typer.Exit()
|
|
372
373
|
try:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
assert (
|
|
377
|
-
pg_db_url.database is not None
|
|
378
|
-
), f"Database name is required in URL: {pg_db_url.render_as_string(hide_password=True)}"
|
|
379
|
-
# Resolve system database name
|
|
380
|
-
sysdb_name = (
|
|
381
|
-
sys_db_name
|
|
382
|
-
if sys_db_name
|
|
383
|
-
else (pg_db_url.database + SystemSchema.sysdb_suffix)
|
|
384
|
-
)
|
|
385
|
-
reset_system_database(
|
|
386
|
-
postgres_db_url=pg_db_url.set(database="postgres"), sysdb_name=sysdb_name
|
|
374
|
+
system_database_url, application_database_url = _get_db_url(
|
|
375
|
+
system_database_url=system_database_url,
|
|
376
|
+
application_database_url=application_database_url,
|
|
387
377
|
)
|
|
388
|
-
|
|
378
|
+
SystemDatabase.reset_system_database(system_database_url)
|
|
379
|
+
except Exception as e:
|
|
389
380
|
typer.echo(f"Error resetting system database: {str(e)}")
|
|
390
381
|
return
|
|
391
382
|
|
|
@@ -408,7 +399,7 @@ def debug(
|
|
|
408
399
|
|
|
409
400
|
@workflow.command(help="List workflows for your application")
|
|
410
401
|
def list(
|
|
411
|
-
|
|
402
|
+
application_database_url: Annotated[
|
|
412
403
|
typing.Optional[str],
|
|
413
404
|
typer.Option(
|
|
414
405
|
"--db-url",
|
|
@@ -416,6 +407,14 @@ def list(
|
|
|
416
407
|
help="Your DBOS application database URL",
|
|
417
408
|
),
|
|
418
409
|
] = None,
|
|
410
|
+
system_database_url: Annotated[
|
|
411
|
+
typing.Optional[str],
|
|
412
|
+
typer.Option(
|
|
413
|
+
"--sys-db-url",
|
|
414
|
+
"-s",
|
|
415
|
+
help="Your DBOS system database URL",
|
|
416
|
+
),
|
|
417
|
+
] = None,
|
|
419
418
|
limit: Annotated[
|
|
420
419
|
int,
|
|
421
420
|
typer.Option("--limit", "-l", help="Limit the results returned"),
|
|
@@ -428,7 +427,7 @@ def list(
|
|
|
428
427
|
typing.Optional[str],
|
|
429
428
|
typer.Option(
|
|
430
429
|
"--start-time",
|
|
431
|
-
"-
|
|
430
|
+
"-t",
|
|
432
431
|
help="Retrieve workflows starting after this timestamp (ISO 8601 format)",
|
|
433
432
|
),
|
|
434
433
|
] = None,
|
|
@@ -481,7 +480,15 @@ def list(
|
|
|
481
480
|
),
|
|
482
481
|
] = None,
|
|
483
482
|
) -> None:
|
|
484
|
-
|
|
483
|
+
system_database_url, application_database_url = _get_db_url(
|
|
484
|
+
system_database_url=system_database_url,
|
|
485
|
+
application_database_url=application_database_url,
|
|
486
|
+
)
|
|
487
|
+
client = DBOSClient(
|
|
488
|
+
application_database_url=application_database_url,
|
|
489
|
+
system_database_url=system_database_url,
|
|
490
|
+
)
|
|
491
|
+
workflows = client.list_workflows(
|
|
485
492
|
limit=limit,
|
|
486
493
|
offset=offset,
|
|
487
494
|
sort_desc=sort_desc,
|
|
@@ -498,7 +505,7 @@ def list(
|
|
|
498
505
|
@workflow.command(help="Retrieve the status of a workflow")
|
|
499
506
|
def get(
|
|
500
507
|
workflow_id: Annotated[str, typer.Argument()],
|
|
501
|
-
|
|
508
|
+
application_database_url: Annotated[
|
|
502
509
|
typing.Optional[str],
|
|
503
510
|
typer.Option(
|
|
504
511
|
"--db-url",
|
|
@@ -506,19 +513,31 @@ def get(
|
|
|
506
513
|
help="Your DBOS application database URL",
|
|
507
514
|
),
|
|
508
515
|
] = None,
|
|
516
|
+
system_database_url: Annotated[
|
|
517
|
+
typing.Optional[str],
|
|
518
|
+
typer.Option(
|
|
519
|
+
"--sys-db-url",
|
|
520
|
+
"-s",
|
|
521
|
+
help="Your DBOS system database URL",
|
|
522
|
+
),
|
|
523
|
+
] = None,
|
|
509
524
|
) -> None:
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
525
|
+
system_database_url, application_database_url = _get_db_url(
|
|
526
|
+
system_database_url=system_database_url,
|
|
527
|
+
application_database_url=application_database_url,
|
|
528
|
+
)
|
|
529
|
+
client = DBOSClient(
|
|
530
|
+
application_database_url=application_database_url,
|
|
531
|
+
system_database_url=system_database_url,
|
|
514
532
|
)
|
|
533
|
+
status = client.retrieve_workflow(workflow_id=workflow_id).get_status()
|
|
515
534
|
print(jsonpickle.encode(status, unpicklable=False))
|
|
516
535
|
|
|
517
536
|
|
|
518
537
|
@workflow.command(help="List the steps of a workflow")
|
|
519
538
|
def steps(
|
|
520
539
|
workflow_id: Annotated[str, typer.Argument()],
|
|
521
|
-
|
|
540
|
+
application_database_url: Annotated[
|
|
522
541
|
typing.Optional[str],
|
|
523
542
|
typer.Option(
|
|
524
543
|
"--db-url",
|
|
@@ -526,10 +545,26 @@ def steps(
|
|
|
526
545
|
help="Your DBOS application database URL",
|
|
527
546
|
),
|
|
528
547
|
] = None,
|
|
548
|
+
system_database_url: Annotated[
|
|
549
|
+
typing.Optional[str],
|
|
550
|
+
typer.Option(
|
|
551
|
+
"--sys-db-url",
|
|
552
|
+
"-s",
|
|
553
|
+
help="Your DBOS system database URL",
|
|
554
|
+
),
|
|
555
|
+
] = None,
|
|
529
556
|
) -> None:
|
|
557
|
+
system_database_url, application_database_url = _get_db_url(
|
|
558
|
+
system_database_url=system_database_url,
|
|
559
|
+
application_database_url=application_database_url,
|
|
560
|
+
)
|
|
561
|
+
client = DBOSClient(
|
|
562
|
+
application_database_url=application_database_url,
|
|
563
|
+
system_database_url=system_database_url,
|
|
564
|
+
)
|
|
530
565
|
print(
|
|
531
566
|
jsonpickle.encode(
|
|
532
|
-
|
|
567
|
+
client.list_workflow_steps(workflow_id=workflow_id),
|
|
533
568
|
unpicklable=False,
|
|
534
569
|
)
|
|
535
570
|
)
|
|
@@ -540,7 +575,7 @@ def steps(
|
|
|
540
575
|
)
|
|
541
576
|
def cancel(
|
|
542
577
|
workflow_id: Annotated[str, typer.Argument()],
|
|
543
|
-
|
|
578
|
+
application_database_url: Annotated[
|
|
544
579
|
typing.Optional[str],
|
|
545
580
|
typer.Option(
|
|
546
581
|
"--db-url",
|
|
@@ -548,14 +583,30 @@ def cancel(
|
|
|
548
583
|
help="Your DBOS application database URL",
|
|
549
584
|
),
|
|
550
585
|
] = None,
|
|
586
|
+
system_database_url: Annotated[
|
|
587
|
+
typing.Optional[str],
|
|
588
|
+
typer.Option(
|
|
589
|
+
"--sys-db-url",
|
|
590
|
+
"-s",
|
|
591
|
+
help="Your DBOS system database URL",
|
|
592
|
+
),
|
|
593
|
+
] = None,
|
|
551
594
|
) -> None:
|
|
552
|
-
|
|
595
|
+
system_database_url, application_database_url = _get_db_url(
|
|
596
|
+
system_database_url=system_database_url,
|
|
597
|
+
application_database_url=application_database_url,
|
|
598
|
+
)
|
|
599
|
+
client = DBOSClient(
|
|
600
|
+
application_database_url=application_database_url,
|
|
601
|
+
system_database_url=system_database_url,
|
|
602
|
+
)
|
|
603
|
+
client.cancel_workflow(workflow_id=workflow_id)
|
|
553
604
|
|
|
554
605
|
|
|
555
606
|
@workflow.command(help="Resume a workflow that has been cancelled")
|
|
556
607
|
def resume(
|
|
557
608
|
workflow_id: Annotated[str, typer.Argument()],
|
|
558
|
-
|
|
609
|
+
application_database_url: Annotated[
|
|
559
610
|
typing.Optional[str],
|
|
560
611
|
typer.Option(
|
|
561
612
|
"--db-url",
|
|
@@ -563,14 +614,32 @@ def resume(
|
|
|
563
614
|
help="Your DBOS application database URL",
|
|
564
615
|
),
|
|
565
616
|
] = None,
|
|
617
|
+
system_database_url: Annotated[
|
|
618
|
+
typing.Optional[str],
|
|
619
|
+
typer.Option(
|
|
620
|
+
"--sys-db-url",
|
|
621
|
+
"-s",
|
|
622
|
+
help="Your DBOS system database URL",
|
|
623
|
+
),
|
|
624
|
+
] = None,
|
|
566
625
|
) -> None:
|
|
567
|
-
|
|
626
|
+
system_database_url, application_database_url = _get_db_url(
|
|
627
|
+
system_database_url=system_database_url,
|
|
628
|
+
application_database_url=application_database_url,
|
|
629
|
+
)
|
|
630
|
+
client = DBOSClient(
|
|
631
|
+
application_database_url=application_database_url,
|
|
632
|
+
system_database_url=system_database_url,
|
|
633
|
+
)
|
|
634
|
+
client.resume_workflow(workflow_id=workflow_id)
|
|
568
635
|
|
|
569
636
|
|
|
570
|
-
@workflow.command(
|
|
637
|
+
@workflow.command(
|
|
638
|
+
help="[DEPRECATED - Use fork instead] Restart a workflow from the beginning with a new id"
|
|
639
|
+
)
|
|
571
640
|
def restart(
|
|
572
641
|
workflow_id: Annotated[str, typer.Argument()],
|
|
573
|
-
|
|
642
|
+
application_database_url: Annotated[
|
|
574
643
|
typing.Optional[str],
|
|
575
644
|
typer.Option(
|
|
576
645
|
"--db-url",
|
|
@@ -578,12 +647,24 @@ def restart(
|
|
|
578
647
|
help="Your DBOS application database URL",
|
|
579
648
|
),
|
|
580
649
|
] = None,
|
|
650
|
+
system_database_url: Annotated[
|
|
651
|
+
typing.Optional[str],
|
|
652
|
+
typer.Option(
|
|
653
|
+
"--sys-db-url",
|
|
654
|
+
"-s",
|
|
655
|
+
help="Your DBOS system database URL",
|
|
656
|
+
),
|
|
657
|
+
] = None,
|
|
581
658
|
) -> None:
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
659
|
+
system_database_url, application_database_url = _get_db_url(
|
|
660
|
+
system_database_url=system_database_url,
|
|
661
|
+
application_database_url=application_database_url,
|
|
662
|
+
)
|
|
663
|
+
client = DBOSClient(
|
|
664
|
+
application_database_url=application_database_url,
|
|
665
|
+
system_database_url=system_database_url,
|
|
586
666
|
)
|
|
667
|
+
status = client.fork_workflow(workflow_id=workflow_id, start_step=1).get_status()
|
|
587
668
|
print(jsonpickle.encode(status, unpicklable=False))
|
|
588
669
|
|
|
589
670
|
|
|
@@ -596,11 +677,27 @@ def fork(
|
|
|
596
677
|
int,
|
|
597
678
|
typer.Option(
|
|
598
679
|
"--step",
|
|
599
|
-
"-
|
|
680
|
+
"-S",
|
|
600
681
|
help="Restart from this step",
|
|
601
682
|
),
|
|
602
683
|
] = 1,
|
|
603
|
-
|
|
684
|
+
forked_workflow_id: Annotated[
|
|
685
|
+
typing.Optional[str],
|
|
686
|
+
typer.Option(
|
|
687
|
+
"--forked-workflow-id",
|
|
688
|
+
"-f",
|
|
689
|
+
help="Custom ID for the forked workflow",
|
|
690
|
+
),
|
|
691
|
+
] = None,
|
|
692
|
+
application_version: Annotated[
|
|
693
|
+
typing.Optional[str],
|
|
694
|
+
typer.Option(
|
|
695
|
+
"--application-version",
|
|
696
|
+
"-v",
|
|
697
|
+
help="Custom application version for the forked workflow",
|
|
698
|
+
),
|
|
699
|
+
] = None,
|
|
700
|
+
application_database_url: Annotated[
|
|
604
701
|
typing.Optional[str],
|
|
605
702
|
typer.Option(
|
|
606
703
|
"--db-url",
|
|
@@ -608,18 +705,43 @@ def fork(
|
|
|
608
705
|
help="Your DBOS application database URL",
|
|
609
706
|
),
|
|
610
707
|
] = None,
|
|
708
|
+
system_database_url: Annotated[
|
|
709
|
+
typing.Optional[str],
|
|
710
|
+
typer.Option(
|
|
711
|
+
"--sys-db-url",
|
|
712
|
+
"-s",
|
|
713
|
+
help="Your DBOS system database URL",
|
|
714
|
+
),
|
|
715
|
+
] = None,
|
|
611
716
|
) -> None:
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
.get_status()
|
|
717
|
+
system_database_url, application_database_url = _get_db_url(
|
|
718
|
+
system_database_url=system_database_url,
|
|
719
|
+
application_database_url=application_database_url,
|
|
616
720
|
)
|
|
721
|
+
client = DBOSClient(
|
|
722
|
+
application_database_url=application_database_url,
|
|
723
|
+
system_database_url=system_database_url,
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
if forked_workflow_id is not None:
|
|
727
|
+
with SetWorkflowID(forked_workflow_id):
|
|
728
|
+
status = client.fork_workflow(
|
|
729
|
+
workflow_id=workflow_id,
|
|
730
|
+
start_step=step,
|
|
731
|
+
application_version=application_version,
|
|
732
|
+
).get_status()
|
|
733
|
+
else:
|
|
734
|
+
status = client.fork_workflow(
|
|
735
|
+
workflow_id=workflow_id,
|
|
736
|
+
start_step=step,
|
|
737
|
+
application_version=application_version,
|
|
738
|
+
).get_status()
|
|
617
739
|
print(jsonpickle.encode(status, unpicklable=False))
|
|
618
740
|
|
|
619
741
|
|
|
620
742
|
@queue.command(name="list", help="List enqueued functions for your application")
|
|
621
743
|
def list_queue(
|
|
622
|
-
|
|
744
|
+
application_database_url: Annotated[
|
|
623
745
|
typing.Optional[str],
|
|
624
746
|
typer.Option(
|
|
625
747
|
"--db-url",
|
|
@@ -627,6 +749,14 @@ def list_queue(
|
|
|
627
749
|
help="Your DBOS application database URL",
|
|
628
750
|
),
|
|
629
751
|
] = None,
|
|
752
|
+
system_database_url: Annotated[
|
|
753
|
+
typing.Optional[str],
|
|
754
|
+
typer.Option(
|
|
755
|
+
"--sys-db-url",
|
|
756
|
+
"-s",
|
|
757
|
+
help="Your DBOS system database URL",
|
|
758
|
+
),
|
|
759
|
+
] = None,
|
|
630
760
|
limit: Annotated[
|
|
631
761
|
typing.Optional[int],
|
|
632
762
|
typer.Option("--limit", "-l", help="Limit the results returned"),
|
|
@@ -635,7 +765,7 @@ def list_queue(
|
|
|
635
765
|
typing.Optional[str],
|
|
636
766
|
typer.Option(
|
|
637
767
|
"--start-time",
|
|
638
|
-
"-
|
|
768
|
+
"-t",
|
|
639
769
|
help="Retrieve functions starting after this timestamp (ISO 8601 format)",
|
|
640
770
|
),
|
|
641
771
|
] = None,
|
|
@@ -688,7 +818,15 @@ def list_queue(
|
|
|
688
818
|
),
|
|
689
819
|
] = None,
|
|
690
820
|
) -> None:
|
|
691
|
-
|
|
821
|
+
system_database_url, application_database_url = _get_db_url(
|
|
822
|
+
system_database_url=system_database_url,
|
|
823
|
+
application_database_url=application_database_url,
|
|
824
|
+
)
|
|
825
|
+
client = DBOSClient(
|
|
826
|
+
application_database_url=application_database_url,
|
|
827
|
+
system_database_url=system_database_url,
|
|
828
|
+
)
|
|
829
|
+
workflows = client.list_queued_workflows(
|
|
692
830
|
limit=limit,
|
|
693
831
|
offset=offset,
|
|
694
832
|
sort_desc=sort_desc,
|
dbos/cli/migration.py
CHANGED
|
@@ -9,7 +9,7 @@ def migrate_dbos_databases(app_database_url: str, system_database_url: str) -> N
|
|
|
9
9
|
app_db = None
|
|
10
10
|
sys_db = None
|
|
11
11
|
try:
|
|
12
|
-
sys_db = SystemDatabase(
|
|
12
|
+
sys_db = SystemDatabase.create(
|
|
13
13
|
system_database_url=system_database_url,
|
|
14
14
|
engine_kwargs={
|
|
15
15
|
"pool_timeout": 30,
|
|
@@ -17,7 +17,7 @@ def migrate_dbos_databases(app_database_url: str, system_database_url: str) -> N
|
|
|
17
17
|
"pool_size": 2,
|
|
18
18
|
},
|
|
19
19
|
)
|
|
20
|
-
app_db = ApplicationDatabase(
|
|
20
|
+
app_db = ApplicationDatabase.create(
|
|
21
21
|
database_url=app_database_url,
|
|
22
22
|
engine_kwargs={
|
|
23
23
|
"pool_timeout": 30,
|
dbos/dbos-config.schema.json
CHANGED
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"type": ["string", "null"],
|
|
20
20
|
"description": "The URL of the application database"
|
|
21
21
|
},
|
|
22
|
+
"system_database_url": {
|
|
23
|
+
"type": ["string", "null"],
|
|
24
|
+
"description": "The URL of the system database"
|
|
25
|
+
},
|
|
22
26
|
"database": {
|
|
23
27
|
"type": "object",
|
|
24
28
|
"additionalProperties": false,
|