fastapi-cloud-cli 0.26.0__py3-none-any.whl → 0.27.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.
@@ -1 +1 @@
1
- __version__ = "0.26.0"
1
+ __version__ = "0.27.0"
@@ -100,6 +100,8 @@ class DeploymentStatus(str, Enum):
100
100
  waiting_upload = "waiting_upload"
101
101
  upload_cancelled = "upload_cancelled"
102
102
  ready_for_build = "ready_for_build"
103
+ build_skipped_filtered = "build_skipped_filtered"
104
+ build_skipped_superseded = "build_skipped_superseded"
103
105
  building = "building"
104
106
  extracting = "extracting"
105
107
  extracting_failed = "extracting_failed"
@@ -120,12 +122,20 @@ class DeploymentStatus(str, Enum):
120
122
  expired = "expired"
121
123
  failed = "failed"
122
124
 
125
+ unknown = "unknown"
126
+
127
+ @classmethod
128
+ def _missing_(cls, value: object) -> "DeploymentStatus":
129
+ return cls.unknown
130
+
123
131
  @classmethod
124
132
  def to_human_readable(cls, status: "DeploymentStatus") -> str:
125
133
  return {
126
134
  cls.waiting_upload: "Awaiting Upload",
127
135
  cls.upload_cancelled: "Upload Cancelled",
128
136
  cls.ready_for_build: "Build Queued",
137
+ cls.build_skipped_filtered: "Build Skipped (Filtered)",
138
+ cls.build_skipped_superseded: "Build Skipped (Superseded)",
129
139
  cls.building: "Building",
130
140
  cls.extracting: "Extracting Upload",
131
141
  cls.extracting_failed: "Extraction Failed",
@@ -145,6 +155,7 @@ class DeploymentStatus(str, Enum):
145
155
  cls.degraded: "Degraded",
146
156
  cls.expired: "Expired",
147
157
  cls.failed: "Failed",
158
+ cls.unknown: "Unknown",
148
159
  }[status]
149
160
 
150
161
 
@@ -167,10 +178,15 @@ BUILD_FAILED_STATUSES = {
167
178
  DeploymentStatus.extracting_failed_archive_too_large,
168
179
  }
169
180
  FAILED_STATUSES = BUILD_FAILED_STATUSES | {
181
+ DeploymentStatus.build_skipped_filtered,
182
+ DeploymentStatus.build_skipped_superseded,
170
183
  DeploymentStatus.failed,
171
184
  DeploymentStatus.verifying_failed,
172
185
  DeploymentStatus.verification_failed_oom,
173
186
  DeploymentStatus.deploying_failed,
174
187
  DeploymentStatus.deploying_skipped,
188
+ DeploymentStatus.degraded,
189
+ DeploymentStatus.degraded_oom,
190
+ DeploymentStatus.expired,
175
191
  }
176
192
  TERMINAL_STATUSES = SUCCESSFUL_STATUSES | FAILED_STATUSES
@@ -57,6 +57,7 @@ def _should_exclude_entry(path: Path) -> bool:
57
57
  ".git",
58
58
  ".gitignore",
59
59
  ".fastapicloudignore",
60
+ ".fastapicloud",
60
61
  ]
61
62
 
62
63
  if any(part in path.parts for part in parts_to_exclude):
@@ -80,7 +81,8 @@ def _rignore_walk(path: Path) -> rignore.Walker:
80
81
  )
81
82
 
82
83
 
83
- def archive(path: Path, tar_path: Path) -> Path:
84
+ def archive(path: Path, tar_path: Path) -> int:
85
+ """Write the files to upload into `tar_path` and return how many there were."""
84
86
  logger.debug("Starting archive creation for path: %s", path)
85
87
  files = _rignore_walk(path)
86
88
 
@@ -98,7 +100,7 @@ def archive(path: Path, tar_path: Path) -> Path:
98
100
  file_count += 1
99
101
 
100
102
  logger.debug("Archive created successfully with %s files", file_count)
101
- return tar_path
103
+ return file_count
102
104
 
103
105
 
104
106
  def _get_large_files(path: Path, threshold_mb: int) -> list[tuple[Path, int]]:
@@ -21,6 +21,7 @@ class AppResponse(BaseModel):
21
21
  id: str
22
22
  slug: str
23
23
  directory: str | None
24
+ github_repository: str | None = None
24
25
 
25
26
 
26
27
  class CreateDeploymentResponse(BaseModel):
@@ -99,16 +99,61 @@ def _render_linked_app_not_found(
99
99
  )
100
100
 
101
101
 
102
+ def _confirm_home_directory_deploy(
103
+ toolkit: FastAPIRichToolkit, *, json_output: bool
104
+ ) -> None:
105
+ if json_output or is_ci_enabled():
106
+ toolkit.fail(
107
+ "invalid_input",
108
+ "Refusing to deploy your home directory.",
109
+ hint="Pass the directory of your app, or use --force.",
110
+ )
111
+
112
+ if not toolkit.confirm(
113
+ "You are deploying your home directory. Do you want to continue?",
114
+ default=False,
115
+ emoji="🚨",
116
+ ):
117
+ toolkit.print_line()
118
+ toolkit.print("Deployment cancelled.")
119
+ raise typer.Exit(0)
120
+
121
+ toolkit.print_line()
122
+
123
+
124
+ def _check_app_directory(
125
+ toolkit: FastAPIRichToolkit, *, app: AppResponse, path_to_deploy: Path
126
+ ) -> None:
127
+ """Stop before uploading when the app's directory isn't in the upload."""
128
+ if app.directory is None or (path_to_deploy / app.directory).is_dir():
129
+ return
130
+
131
+ if app.github_repository:
132
+ hint = (
133
+ f"This app is connected to {app.github_repository} and builds from "
134
+ f"`{app.directory}` in that repository. Run "
135
+ f"`fastapi deploy --app-id {app.id}` from the repository root, or use --force."
136
+ )
137
+ else:
138
+ hint = (
139
+ "Deploy from the folder that contains it, update the app directory "
140
+ "with `fastapi cloud apps update --directory`, or use --force."
141
+ )
142
+
143
+ toolkit.fail(
144
+ "invalid_input",
145
+ f"The app directory `{app.directory}` doesn't exist in {path_to_deploy}.",
146
+ hint=hint,
147
+ )
148
+
149
+
102
150
  @app.command()
103
151
  @cloud_app.command()
104
152
  def deploy(
105
153
  path: Annotated[
106
154
  Path | None,
107
155
  typer.Argument(
108
- help=(
109
- "Path to the directory with your app's pyproject.toml "
110
- "(defaults to current directory)"
111
- )
156
+ help="Path to the directory to deploy (defaults to current directory)"
112
157
  ),
113
158
  ] = None,
114
159
  skip_wait: Annotated[
@@ -131,6 +176,13 @@ def deploy(
131
176
  ),
132
177
  ] = 10,
133
178
  json_output: JsonOutputOption = False,
179
+ force: Annotated[
180
+ bool,
181
+ typer.Option(
182
+ "--force",
183
+ help="Deploy even if the app directory is missing or the path is your home directory",
184
+ ),
185
+ ] = False,
134
186
  ) -> Any:
135
187
  """
136
188
  Deploy a [bold]FastAPI[/bold] app to FastAPI Cloud.
@@ -212,6 +264,9 @@ def deploy(
212
264
  path_to_deploy = path or Path.cwd()
213
265
  logger.debug("Deploying from path: %s", path_to_deploy)
214
266
 
267
+ if not force and path_to_deploy.resolve() == Path.home().resolve():
268
+ _confirm_home_directory_deploy(toolkit, json_output=json_output)
269
+
215
270
  app_config = get_app_config(path_to_deploy)
216
271
 
217
272
  if app_config and provided_app_id and app_config.app_id != provided_app_id:
@@ -230,7 +285,7 @@ def deploy(
230
285
  elif app_config:
231
286
  target_app_id = app_config.app_id
232
287
  else:
233
- if json_output:
288
+ if json_output or is_ci_enabled():
234
289
  toolkit.fail(
235
290
  "missing_required_input",
236
291
  "App ID is required.",
@@ -281,6 +336,9 @@ def deploy(
281
336
 
282
337
  app = cast(AppResponse, app)
283
338
 
339
+ if not force:
340
+ _check_app_directory(toolkit, app=app, path_to_deploy=path_to_deploy)
341
+
284
342
  large_files = _get_large_files(
285
343
  path_to_deploy, threshold_mb=large_file_threshold
286
344
  )
@@ -316,9 +374,19 @@ def deploy(
316
374
  with tempfile.TemporaryDirectory() as temp_dir:
317
375
  logger.debug("Creating archive for deployment")
318
376
  archive_path = Path(temp_dir) / "archive.tar"
319
- archive(path_to_deploy, archive_path)
377
+ file_count = archive(path_to_deploy, archive_path)
320
378
  archive_size = archive_path.stat().st_size
321
379
 
380
+ if file_count == 0:
381
+ toolkit.fail(
382
+ "invalid_input",
383
+ f"Nothing to deploy: no files to upload in {path_to_deploy}.",
384
+ hint=(
385
+ "Check the path, and that .gitignore or "
386
+ ".fastapicloudignore don't exclude your app's files."
387
+ ),
388
+ )
389
+
322
390
  with (
323
391
  toolkit.progress(
324
392
  title="Creating deployment",
@@ -21,6 +21,10 @@ from fastapi_cloud_cli.utils.build_logs import print_build_error
21
21
  from fastapi_cloud_cli.utils.cli import FastAPIRichToolkit
22
22
  from fastapi_cloud_cli.utils.execution import is_ci_enabled
23
23
 
24
+ # The build finished but we couldn't confirm the deployment came up. Distinct
25
+ # from 1 so scripts can tell "still verifying" from "failed".
26
+ UNCONFIRMED_EXIT_CODE = 3
27
+
24
28
  # (bullet emoji, message) — the emoji replaces the progress animation
25
29
  WAITING_MESSAGES = [
26
30
  ("🚀", "Preparing for liftoff! Almost there..."),
@@ -55,6 +59,7 @@ def _verify_deployment(
55
59
  deployment: CreateDeploymentResponse,
56
60
  ) -> None:
57
61
  failed_status: str | None = None
62
+ unconfirmed = False
58
63
 
59
64
  with toolkit.progress(
60
65
  title="Verifying deployment...",
@@ -69,15 +74,18 @@ def _verify_deployment(
69
74
  f"Could not confirm deployment status. "
70
75
  f"Check the dashboard: [link={deployment.dashboard_url}]{deployment.dashboard_url}[/link]"
71
76
  )
72
- return
73
-
74
- if final_status in SUCCESSFUL_STATUSES:
75
- progress.current_message = "Ready the chicken! 🐔"
77
+ unconfirmed = True
76
78
  else:
77
- progress.metadata["done_emoji"] = "❌"
78
- progress.current_message = "Deployment failed"
79
+ if final_status in SUCCESSFUL_STATUSES:
80
+ progress.current_message = "Ready the chicken! 🐔"
81
+ else:
82
+ progress.metadata["done_emoji"] = "❌"
83
+ progress.current_message = "Deployment failed"
84
+
85
+ failed_status = DeploymentStatus.to_human_readable(final_status)
79
86
 
80
- failed_status = DeploymentStatus.to_human_readable(final_status)
87
+ if unconfirmed:
88
+ raise typer.Exit(UNCONFIRMED_EXIT_CODE)
81
89
 
82
90
  if failed_status is not None:
83
91
  toolkit.print_line()
@@ -9,10 +9,7 @@ from rich_toolkit import RichToolkit
9
9
  from fastapi_cloud_cli.api import APIClient
10
10
  from fastapi_cloud_cli.commands._auth import UserCommand, get_user_command_context
11
11
  from fastapi_cloud_cli.commands.integrations.resources._app import resources_app
12
- from fastapi_cloud_cli.commands.integrations.resources.providers import (
13
- PROVIDER_NAMES,
14
- Provider,
15
- )
12
+ from fastapi_cloud_cli.commands.integrations.resources.providers import PROVIDER_NAMES
16
13
  from fastapi_cloud_cli.utils.apps import resolve_app_id_or_fail
17
14
  from fastapi_cloud_cli.utils.cli import get_details_table
18
15
  from fastapi_cloud_cli.utils.dates import format_last_updated
@@ -55,7 +52,6 @@ class ConnectedResourceAPIResponse(BaseModel):
55
52
  class ConnectedResourceBase(BaseModel):
56
53
  id: str
57
54
  name: str
58
- provider: Provider
59
55
  console_url: str
60
56
  environment_variables: list[str]
61
57
  created_at: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastapi-cloud-cli
3
- Version: 0.26.0
3
+ Version: 0.27.0
4
4
  Summary: Deploy and manage FastAPI Cloud apps from the command line 🚀
5
5
  Author-Email: Patrick Arminio <patrick@fastapilabs.com>
6
6
  License: MIT
@@ -33,7 +33,7 @@ Requires-Dist: typer>=0.26.1
33
33
  Requires-Dist: uvicorn[standard]>=0.17.6
34
34
  Requires-Dist: rignore>=0.5.1
35
35
  Requires-Dist: httpx>=0.27.0
36
- Requires-Dist: rich-toolkit>=0.20.5
36
+ Requires-Dist: rich-toolkit>=0.20.6
37
37
  Requires-Dist: pydantic[email]>=2.7.4; python_version < "3.13"
38
38
  Requires-Dist: pydantic[email]>=2.8.0; python_version == "3.13"
39
39
  Requires-Dist: pydantic[email]>=2.12.0; python_version >= "3.14"
@@ -1,13 +1,13 @@
1
- fastapi_cloud_cli-0.26.0.dist-info/METADATA,sha256=cGX_kGGfi9Wqny026UsXThsuq5nm8Vyoqu08Ar2uXJE,3108
2
- fastapi_cloud_cli-0.26.0.dist-info/WHEEL,sha256=VP-D4TPS230sME9Z3vb3INXvo1yt0924YRm5AOsk_dE,90
3
- fastapi_cloud_cli-0.26.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- fastapi_cloud_cli-0.26.0.dist-info/licenses/LICENSE,sha256=FqD5B4VbXJnefprQseE0U8llL6FxojC-i8muZy7YmSU,1086
5
- fastapi_cloud_cli/__init__.py,sha256=S1dNBNSmHJkAHkq1vL1Yg-dFpQk0fri_CstNlL1u5qw,23
1
+ fastapi_cloud_cli-0.27.0.dist-info/METADATA,sha256=wTrM1j5l6VopNGhVL8HYeFeLtuvMq6Ko8fkI2LjQjqA,3108
2
+ fastapi_cloud_cli-0.27.0.dist-info/WHEEL,sha256=IuIk3wbaEnFH1cx75iM2R1CmliRI3dFLXTbRakgvgFQ,90
3
+ fastapi_cloud_cli-0.27.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ fastapi_cloud_cli-0.27.0.dist-info/licenses/LICENSE,sha256=FqD5B4VbXJnefprQseE0U8llL6FxojC-i8muZy7YmSU,1086
5
+ fastapi_cloud_cli/__init__.py,sha256=Hjsc9XQ3AkqXm-5cdlX-H8iKjURzi1FQeWNi2xx34Uo,23
6
6
  fastapi_cloud_cli/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
7
7
  fastapi_cloud_cli/_app.py,sha256=7RNSWWNLEoIN3WwvTBJ3MSKIPPfbbwoLHFJrSYdJjJc,735
8
8
  fastapi_cloud_cli/api/__init__.py,sha256=ORZqOHW7yaKjq0jY7M5pK8J5oyFgMOrWNeBzXMC2fCA,1359
9
9
  fastapi_cloud_cli/api/_errors.py,sha256=NJVIfaKsPDZi-7Y5JlZU0qsZc3BBozEC1bb1RKdGs2Q,3711
10
- fastapi_cloud_cli/api/_models.py,sha256=9h546GVlEi9CJ7vWt7UNfcpubuvnJ2pUgs33gbKrqVc,5469
10
+ fastapi_cloud_cli/api/_models.py,sha256=dfEklsl6TbPWHN9i1SNzz6lLgLXG6LPUglXklnTfUI0,6076
11
11
  fastapi_cloud_cli/api/_retry.py,sha256=SsSG2jid2RjwpHpKRU_YfzzjLKAnk17OjgkyQgPLzxo,2706
12
12
  fastapi_cloud_cli/api/client.py,sha256=kzrU6nx-L2vWJZ99-KCzTpZIPfhVMwrcRcqaMx9TAo4,10884
13
13
  fastapi_cloud_cli/cli.py,sha256=u-ZYE-mN0Ml5XNy11iMR_W8WCqp8d2J6BZ7YH05-CkM,3989
@@ -29,12 +29,12 @@ fastapi_cloud_cli/commands/ci/__init__.py,sha256=q0BSY2Q7EDYMX4P8n95heArjQU1UTgY
29
29
  fastapi_cloud_cli/commands/ci/_app.py,sha256=JCwAXhlWmZPHwgllqK3Fxl5Y5RL1gsBuXEfE4QHDOA0,107
30
30
  fastapi_cloud_cli/commands/ci/print_workflow.py,sha256=8WB_D6daegyiK9kS_k4kPdos7Udp_A6E6WfN4DbLgJA,1384
31
31
  fastapi_cloud_cli/commands/deploy/__init__.py,sha256=myre0p1V1l6ma3v06sUNccT3y2YL7l2nK0bcSIEqQ50,50
32
- fastapi_cloud_cli/commands/deploy/archive.py,sha256=zUihwCBhpUpjWsWf1nAdJD3x3UVX_yTYG4s-9b7MUmk,2920
33
- fastapi_cloud_cli/commands/deploy/cloud.py,sha256=ISsO-cQpdsw2Ia6R9P-TIOMKx1VxD1ylbEx7GjJWRm8,2410
34
- fastapi_cloud_cli/commands/deploy/command.py,sha256=7RQCqlVrqusLl2ZtWYOfQ95nEoixszbHdfQiuocrgqQ,13967
32
+ fastapi_cloud_cli/commands/deploy/archive.py,sha256=GjkzmeOKCJVCywVd10rMLFYpbpwvlTEIWcN5oNxVOng,3030
33
+ fastapi_cloud_cli/commands/deploy/cloud.py,sha256=hF1ZwHU5wbi0fl5kbQDctsQYDZGVM4BjDWdBz2UybMU,2451
34
+ fastapi_cloud_cli/commands/deploy/command.py,sha256=48mn92AT0imm9uBQQn1TdlGYH4-CTsgJEIdDM7ykzxY,16368
35
35
  fastapi_cloud_cli/commands/deploy/configure.py,sha256=2D9MDknTp5yE5ihIE_oHBNgrPY4fcvaItR2dK1SiXVk,4898
36
36
  fastapi_cloud_cli/commands/deploy/upload.py,sha256=TRHKVco06ZKXSLAV80iBy81HswAzSe00GvshOpfkv5s,3185
37
- fastapi_cloud_cli/commands/deploy/wait.py,sha256=f-4xFftueemMtdONqeA65x0UqksS32bc6XOiZatvFpg,6723
37
+ fastapi_cloud_cli/commands/deploy/wait.py,sha256=LLmQ8T6bUoZj_JY7dQ43rDK1c11eocjxFjitsinJ_Zw,7032
38
38
  fastapi_cloud_cli/commands/deployments.py,sha256=ZWbfdkkwkmMqtR8ysrnR9bAlnEAsoPAg9DlQbTJuYfU,14319
39
39
  fastapi_cloud_cli/commands/domains/__init__.py,sha256=t0kcyNvJVHITc6xPWvsTMKCUpWd3Y_Ur-F2V66UyGeY,106
40
40
  fastapi_cloud_cli/commands/domains/_app.py,sha256=h-6saPMt--q5vUM3fKxI-kf0c7Ej-5bY9lXYMVsMF9I,120
@@ -61,7 +61,7 @@ fastapi_cloud_cli/commands/integrations/resources/__init__.py,sha256=XthSeuJ-KHe
61
61
  fastapi_cloud_cli/commands/integrations/resources/_app.py,sha256=weporYT5Vgn9vpwlu2s7jl4-zX7ZjO371uiuxtkYHEI,121
62
62
  fastapi_cloud_cli/commands/integrations/resources/connect.py,sha256=dV5bsyHhYcrYZkfd-6HiwTvqGO2M8Pl_fpMyXfWaDWg,4406
63
63
  fastapi_cloud_cli/commands/integrations/resources/disconnect.py,sha256=QganB4O_Ht0gbauCGoZPJfGfqeEMwm8_vcT77bObK10,7718
64
- fastapi_cloud_cli/commands/integrations/resources/get.py,sha256=dYEcyPTrwf7BpSSe-vagwQDPSrpDbybmv9cCgBoRPLI,6468
64
+ fastapi_cloud_cli/commands/integrations/resources/get.py,sha256=E4hXpZeS5DX0wFjra6vrlTO5QrP5M3q5-mbS8T_RYHc,6422
65
65
  fastapi_cloud_cli/commands/integrations/resources/list.py,sha256=AKyBWgZxpssor3jzFUFM83vpe684IzGnZ_iUj3d5zB0,3488
66
66
  fastapi_cloud_cli/commands/integrations/resources/providers.py,sha256=-9RnA7qW-rYaBm2q86bQlnqTvzorjjrbT0XBwwwY7uA,232
67
67
  fastapi_cloud_cli/commands/login.py,sha256=xGUnxXHUNxRw6G6_spageAQ8lj06ikBXsPhxrNztyt0,4048
@@ -95,4 +95,4 @@ fastapi_cloud_cli/utils/progress_file.py,sha256=GMK-OgS1pr2IgfBpJgwPqkb2k37W0b2C
95
95
  fastapi_cloud_cli/utils/sentry.py,sha256=C_KlTV8JCtB3slrCJLNoTo6beM87rWjxAr92uwmWLR0,599
96
96
  fastapi_cloud_cli/utils/teams.py,sha256=PSCL-hySKcUU_pz45xBEKeB8NCbWLBCGlgx_GFLZ-2w,2007
97
97
  fastapi_cloud_cli/utils/version_check.py,sha256=-iOus8nWNsQn9FnC5tZD0iCftjUdeCj-RFskPLz1KZE,5209
98
- fastapi_cloud_cli-0.26.0.dist-info/RECORD,,
98
+ fastapi_cloud_cli-0.27.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.4.9)
2
+ Generator: pdm-backend (2.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any