Skip to content

Commit 9db0234

Browse files
committed
workflow
1 parent d68b772 commit 9db0234

6 files changed

Lines changed: 75 additions & 45 deletions

File tree

‎.github/workflows/plash_deploy.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
echo '${{ secrets.PLASH_CONFIG }}' > ~/.config/plash_config.json
2424
2525
- name: Checkout repository
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v7
2727

2828
- name: Set up Python
29-
uses: actions/setup-python@v5
29+
uses: actions/setup-python@v6
3030
with:
3131
python-version: '3.13'
3232

@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: Comment PR with preview URL
4141
if: github.event_name == 'pull_request' && (github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'preview-docs'))
42-
uses: actions/github-script@v7
42+
uses: actions/github-script@v9
4343
with:
4444
script: |
4545
const comments = await github.rest.issues.listComments({
@@ -66,4 +66,4 @@ jobs:
6666

6767
- name: Deploy Plash Docs
6868
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
69-
run: bash ./scripts/deploy_docs.sh
69+
run: bash ./scripts/deploy_docs.sh

‎nbs/00_cli.ipynb‎

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@
207207
"\n",
208208
" err = httpx.Response(401, headers={'X-Plash-Error': 'from header'}, text='from body')\n",
209209
" _get_client = lambda: _FakeClient(err)\n",
210-
" test_fail(_mk_auth_req, args=('https://example.com',), contains='from header', exc=PlashError)\n",
210+
" with expect_fail(PlashError, 'from header'): _mk_auth_req('https://example.com')\n",
211211
"\n",
212212
" err = httpx.Response(422, text='from body')\n",
213213
" _get_client = lambda: _FakeClient(err)\n",
214-
" test_fail(_mk_auth_req, args=('https://example.com',), contains='from body', exc=PlashError)\n",
214+
" with expect_fail(PlashError, 'from body'): _mk_auth_req('https://example.com')\n",
215215
"\n",
216216
" err = httpx.Response(503)\n",
217217
" _get_client = lambda: _FakeClient(err)\n",
218-
" test_fail(_mk_auth_req, args=('https://example.com',), contains='HTTP 503', exc=PlashError)\n",
218+
" with expect_fail(PlashError, 'HTTP 503'): _mk_auth_req('https://example.com')\n",
219219
"finally: _get_client = orig_get_client"
220220
]
221221
},
@@ -395,12 +395,12 @@
395395
"# Lets test each failure case:\n",
396396
"with TemporaryDirectory() as td:\n",
397397
" td = Path(td)\n",
398-
" test_fail(_validate_app, args=(td,), contains=\"main.py\")\n",
398+
" with expect_fail(Exception, \"main.py\"): _validate_app(td)\n",
399399
" \n",
400400
" # test failure case of deps in both main.py and requirements.txt\n",
401401
" (td / \"requirements.txt\").write_text(\"\")\n",
402402
" (td / \"main.py\").write_text(Path(\"../examples/inline_dependencies/main.py\").read_text())\n",
403-
" test_fail(_validate_app, args=(td,), contains=\"not contain both\")"
403+
" with expect_fail(Exception, \"not contain both\"): _validate_app(td)"
404404
]
405405
},
406406
{
@@ -438,7 +438,8 @@
438438
"def deploy(\n",
439439
" path:Path='.', # Path to project\n",
440440
" name:str=None, # Overrides the .plash file in project root if provided\n",
441-
" _force_data:bool=False): # Overwrite data/ directory during deployment\n",
441+
" _force_data:bool=False # Overwrite data/ directory during deployment\n",
442+
"):\n",
442443
" \"\"\"\n",
443444
" Deploys app to production. By default, this command erases all files in your app which are not in data/.\n",
444445
" Then uploads all files and folders, except paths starting with `.` and except the local data/ directory.\n",
@@ -478,7 +479,7 @@
478479
" try:\n",
479480
" msg = \"Invalid name 'pla.sh': platform-owned domains under 'pla.sh' cannot be used as custom domains.\"\n",
480481
" _get_client = lambda: _FakeClient(httpx.Response(422, text=msg))\n",
481-
" test_fail(deploy, args=(td,), kwargs={'name': 'pla.sh'}, contains='platform-owned domains', exc=PlashError)\n",
482+
" with expect_fail(PlashError, 'platform-owned domains'): deploy(td, name='pla.sh')\n",
482483
" finally: _get_client = orig_get_client"
483484
]
484485
},
@@ -494,7 +495,8 @@
494495
"def _deploy(\n",
495496
" path:Path='.', # Path to project\n",
496497
" name:str=None, # Overrides the .plash file in project root if provided\n",
497-
" force_data:bool=False): # Overwrite data/ directory during deployment\n",
498+
" force_data:bool=False # Overwrite data/ directory during deployment\n",
499+
"):\n",
498500
" print('Initializing deployment...')\n",
499501
" try: res = deploy(path=path, name=name, _force_data=force_data)\n",
500502
" except PlashError as e: return str(e)\n",
@@ -635,16 +637,19 @@
635637
"#| export\n",
636638
"def delete_app(\n",
637639
" path:Path='.', # Path to project\n",
638-
" name:str=None): # Overrides the .plash file in project root if provided\n",
640+
" name:str=None # Overrides the .plash file in project root if provided\n",
641+
"):\n",
639642
" 'Delete your deployed app'\n",
640643
" name = _prep(path, name)\n",
641644
" _mk_auth_req(_endpoint(rt=f\"/delete?name={name}\"), \"delete\")\n",
642645
" return f\"App '{name}' deleted successfully\"\n",
643646
"\n",
644647
"@call_parse\n",
645648
"@delegates(delete_app)\n",
646-
"def _delete(force:bool=False, # Skip confirmation prompt\n",
647-
" **kwargs):\n",
649+
"def _delete(\n",
650+
" force:bool=False, # Skip confirmation prompt\n",
651+
" **kwargs\n",
652+
"):\n",
648653
" 'Delete your deployed app'\n",
649654
" if not force:\n",
650655
" confirm = input(\"Are you sure you want to delete the app? [y/N]: \")\n",
@@ -720,7 +725,8 @@
720725
"#| export\n",
721726
"def start_app(\n",
722727
" path:Path='.', # Path to project\n",
723-
" name:str=None): # Overrides the .plash file in project root if provided\n",
728+
" name:str=None # Overrides the .plash file in project root if provided\n",
729+
"):\n",
724730
" 'Start your deployed app'\n",
725731
" name = _prep(path, name)\n",
726732
" _mk_auth_req(_endpoint(rt=f\"/start?name={name}\"))\n",
@@ -790,7 +796,8 @@
790796
"#| export\n",
791797
"def stop_app(\n",
792798
" path:Path='.', # Path to project\n",
793-
" name:str=None): # Overrides the .plash file in project root if provided\n",
799+
" name:str=None # Overrides the .plash file in project root if provided\n",
800+
"):\n",
794801
" 'Stop your deployed app'\n",
795802
" name = _prep(path, name)\n",
796803
" _mk_auth_req(_endpoint(rt=f\"/stop?name={name}\"))\n",
@@ -872,16 +879,19 @@
872879
"def logs(\n",
873880
" path:Path='.', # Path to project\n",
874881
" name:str=None, # Overrides the .plash file in project root if provided\n",
875-
" mode:log_modes='build'): # Choose between build or app logs\n",
882+
" mode:log_modes='build' # Choose between build or app logs\n",
883+
"):\n",
876884
" 'Get logs for your deployed app'\n",
877885
" name = _prep(path, name)\n",
878886
" r = _mk_auth_req(_endpoint(rt=f\"/logs?name={name}&mode={mode}\"))\n",
879887
" return r.text\n",
880888
"\n",
881889
"@call_parse\n",
882890
"@delegates(logs)\n",
883-
"def _logs(tail:bool=False, # Tail the logs\n",
884-
" **kwargs):\n",
891+
"def _logs(\n",
892+
" tail:bool=False, # Tail the logs\n",
893+
" **kwargs\n",
894+
"):\n",
885895
" try:\n",
886896
" if not tail: return print(logs(**kwargs))\n",
887897
" text = ''\n",
@@ -1013,7 +1023,8 @@
10131023
"def download_app(\n",
10141024
" path:Path='.', # Path to project\n",
10151025
" name:str=None, # Overrides the .plash file in project root if provided\n",
1016-
" save_path:Path=\"./download/\"): # Save path (optional)\n",
1026+
" save_path:Path=\"./download/\" # Save path (optional)\n",
1027+
"):\n",
10171028
" \"Download deployed app to save_path.\"\n",
10181029
" name = _prep(path, name)\n",
10191030
" save_path = Path(save_path)\n",

‎nbs/01_auth.ipynb‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@
115115
"outputs": [],
116116
"source": [
117117
"#| export\n",
118-
"def mk_signin_url(session: dict, # Session dictionary\n",
119-
" email_re: str=None, # Regex filter for allowed email addresses\n",
120-
" hd_re: str=None): # Regex filter for allowed Google hosted domains\n",
118+
"def mk_signin_url(\n",
119+
" session: dict, # Session dictionary\n",
120+
" email_re: str=None, # Regex filter for allowed email addresses\n",
121+
" hd_re: str=None # Regex filter for allowed Google hosted domains\n",
122+
"):\n",
121123
" \"Generate a Google Sign-In URL for Plash authentication.\"\n",
122124
" if not _in_prod: return f\"{signin_completed_rt}?signin_reply=mock-sign-in-reply\"\n",
123125
" res = _signin_url(email_re, hd_re)\n",
@@ -196,8 +198,10 @@
196198
"outputs": [],
197199
"source": [
198200
"#| export\n",
199-
"def goog_id_from_signin_reply(session: dict, # Session dictionary containing 'req_id'\n",
200-
" reply: str): # The JWT reply string from Plash after Google authentication\n",
201+
"def goog_id_from_signin_reply(\n",
202+
" session: dict, # Session dictionary containing 'req_id'\n",
203+
" reply: str # The JWT reply string from Plash after Google authentication\n",
204+
"):\n",
201205
" \"Validate Google sign-in reply and returns Google user ID if valid.\"\n",
202206
" if not _in_prod: return '424242424242424242424'\n",
203207
" parsed = _parse_jwt(reply)\n",

‎plash_cli/auth.py‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Client side logic to add Plash Auth to your app
22
3-
Docs: https://AnswerDotAI.github.io/plash_cliauth.html.md"""
3+
Docs: https://AnswerDotAI.github.io/plash_cli/auth.html.md"""
44

55
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_auth.ipynb.
66

@@ -29,9 +29,11 @@ def _signin_url(email_re: str=None, hd_re: str=None):
2929
signin_completed_rt = "/signin_completed"
3030

3131
# %% ../nbs/01_auth.ipynb #74a0a24d
32-
def mk_signin_url(session: dict, # Session dictionary
33-
email_re: str=None, # Regex filter for allowed email addresses
34-
hd_re: str=None): # Regex filter for allowed Google hosted domains
32+
def mk_signin_url(
33+
session: dict, # Session dictionary
34+
email_re: str=None, # Regex filter for allowed email addresses
35+
hd_re: str=None # Regex filter for allowed Google hosted domains
36+
):
3537
"Generate a Google Sign-In URL for Plash authentication."
3638
if not _in_prod: return f"{signin_completed_rt}?signin_reply=mock-sign-in-reply"
3739
res = _signin_url(email_re, hd_re)
@@ -52,8 +54,10 @@ class PlashAuthError(Exception):
5254
pass
5355

5456
# %% ../nbs/01_auth.ipynb #a311ce9a
55-
def goog_id_from_signin_reply(session: dict, # Session dictionary containing 'req_id'
56-
reply: str): # The JWT reply string from Plash after Google authentication
57+
def goog_id_from_signin_reply(
58+
session: dict, # Session dictionary containing 'req_id'
59+
reply: str # The JWT reply string from Plash after Google authentication
60+
):
5761
"Validate Google sign-in reply and returns Google user ID if valid."
5862
if not _in_prod: return '424242424242424242424'
5963
parsed = _parse_jwt(reply)

‎plash_cli/cli.py‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""The Plash CLI tool
22
3-
Docs: https://AnswerDotAI.github.io/plash_clicli.html.md"""
3+
Docs: https://AnswerDotAI.github.io/plash_cli/cli.html.md"""
44

55
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_cli.ipynb.
66

@@ -152,7 +152,8 @@ def create_tar_archive(path:Path, force_data:bool=False) -> tuple[io.BytesIO, in
152152
def deploy(
153153
path:Path='.', # Path to project
154154
name:str=None, # Overrides the .plash file in project root if provided
155-
_force_data:bool=False): # Overwrite data/ directory during deployment
155+
_force_data:bool=False # Overwrite data/ directory during deployment
156+
):
156157
"""
157158
Deploys app to production. By default, this command erases all files in your app which are not in data/.
158159
Then uploads all files and folders, except paths starting with `.` and except the local data/ directory.
@@ -180,7 +181,8 @@ def deploy(
180181
def _deploy(
181182
path:Path='.', # Path to project
182183
name:str=None, # Overrides the .plash file in project root if provided
183-
force_data:bool=False): # Overwrite data/ directory during deployment
184+
force_data:bool=False # Overwrite data/ directory during deployment
185+
):
184186
print('Initializing deployment...')
185187
try: res = deploy(path=path, name=name, _force_data=force_data)
186188
except PlashError as e: return str(e)
@@ -203,16 +205,19 @@ def view(
203205
# %% ../nbs/00_cli.ipynb #43535aef
204206
def delete_app(
205207
path:Path='.', # Path to project
206-
name:str=None): # Overrides the .plash file in project root if provided
208+
name:str=None # Overrides the .plash file in project root if provided
209+
):
207210
'Delete your deployed app'
208211
name = _prep(path, name)
209212
_mk_auth_req(_endpoint(rt=f"/delete?name={name}"), "delete")
210213
return f"App '{name}' deleted successfully"
211214

212215
@call_parse
213216
@delegates(delete_app)
214-
def _delete(force:bool=False, # Skip confirmation prompt
215-
**kwargs):
217+
def _delete(
218+
force:bool=False, # Skip confirmation prompt
219+
**kwargs
220+
):
216221
'Delete your deployed app'
217222
if not force:
218223
confirm = input("Are you sure you want to delete the app? [y/N]: ")
@@ -224,7 +229,8 @@ def _delete(force:bool=False, # Skip confirmation prompt
224229
# %% ../nbs/00_cli.ipynb #d72ccd37
225230
def start_app(
226231
path:Path='.', # Path to project
227-
name:str=None): # Overrides the .plash file in project root if provided
232+
name:str=None # Overrides the .plash file in project root if provided
233+
):
228234
'Start your deployed app'
229235
name = _prep(path, name)
230236
_mk_auth_req(_endpoint(rt=f"/start?name={name}"))
@@ -240,7 +246,8 @@ def _start(**kwargs):
240246
# %% ../nbs/00_cli.ipynb #ace91510
241247
def stop_app(
242248
path:Path='.', # Path to project
243-
name:str=None): # Overrides the .plash file in project root if provided
249+
name:str=None # Overrides the .plash file in project root if provided
250+
):
244251
'Stop your deployed app'
245252
name = _prep(path, name)
246253
_mk_auth_req(_endpoint(rt=f"/stop?name={name}"))
@@ -260,16 +267,19 @@ def _stop(**kwargs):
260267
def logs(
261268
path:Path='.', # Path to project
262269
name:str=None, # Overrides the .plash file in project root if provided
263-
mode:log_modes='build'): # Choose between build or app logs
270+
mode:log_modes='build' # Choose between build or app logs
271+
):
264272
'Get logs for your deployed app'
265273
name = _prep(path, name)
266274
r = _mk_auth_req(_endpoint(rt=f"/logs?name={name}&mode={mode}"))
267275
return r.text
268276

269277
@call_parse
270278
@delegates(logs)
271-
def _logs(tail:bool=False, # Tail the logs
272-
**kwargs):
279+
def _logs(
280+
tail:bool=False, # Tail the logs
281+
**kwargs
282+
):
273283
try:
274284
if not tail: return print(logs(**kwargs))
275285
text = ''
@@ -292,7 +302,8 @@ def _is_dir_empty(self:Path): return next(self.iterdir(), None) is None
292302
def download_app(
293303
path:Path='.', # Path to project
294304
name:str=None, # Overrides the .plash file in project root if provided
295-
save_path:Path="./download/"): # Save path (optional)
305+
save_path:Path="./download/" # Save path (optional)
306+
):
296307
"Download deployed app to save_path."
297308
name = _prep(path, name)
298309
save_path = Path(save_path)

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = {text = "Apache-2.0"}
1212
authors = [{name = "Jeremy Howard", email = "info@fast.ai"}]
1313
keywords = ['nbdev', 'jupyter', 'notebook', 'python']
1414
classifiers = ["Natural Language :: English", "Intended Audience :: Developers", "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"]
15-
dependencies = ['fastcore', 'httpx>=0.28.1', 'python-dotenv', 'pyjwt', 'cryptography']
15+
dependencies = ['fastcore>=1.12.27', 'httpx>=0.28.1', 'python-dotenv', 'pyjwt', 'cryptography']
1616

1717
[project.urls]
1818
Repository = "https://github.com/AnswerDotAI/plash_cli"

0 commit comments

Comments
 (0)