Skip to content

Conversation

@bcwu
Copy link
Contributor

@bcwu bcwu commented Mar 9, 2023

Description

  • Refactor deploy html based on the new Manifest and Bundle classes
  • Add missing unit test coverage for deploy html

@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch from 010c686 to 32bd359 Compare March 9, 2023 00:32
@bcwu
Copy link
Contributor Author

bcwu commented Mar 9, 2023

fixes #361

@mmarchetti
Copy link
Contributor

I still get a 404 when deploying static content with an index not named index.html.

I deployed with

rsconnect deploy html -n local ./static-test/

and

rsconnect deploy html -n local --entrypoint news.html ./static-test/

@bcwu
Copy link
Contributor Author

bcwu commented Mar 9, 2023

also, fixes #359

@kgartland-rstudio
Copy link
Contributor

kgartland-rstudio commented Mar 9, 2023

Can deploy and render...

single html file: deploy by directory, no entrypoint

  • index.html
  • blue.html (manifest contains proper entrypoint)
  • no html (caught Error: No valid entrypoint found.)

single html file deploy by directory with entrypoint

  • index.html
  • blue.html
  • no html (connect provides handy download page)
    Screen Shot 2023-03-09 at 3 28 15 PM
  • ✅ wrong entrypoint

single html file: deploy by filename

  • index.html
  • blue.html
  • no html
  • wrong entrypoint

single html file: deploy by filename with entrypoint

  • index.html
  • blue.html
  • no html
  • ✅ wrong entrypoint

multi html deploy: deploy by directory, no entrypoint

  • index.html
  • blue.html (manifest contains proper entrypoint)
  • no html (caught Error: No valid entrypoint found.)

multi html deploy: deploy by file

  • ✅ specifying two files

@kgartland-rstudio
Copy link
Contributor

When specifying an entrypoint that doesn't exist we don't catch the error and give a reasonable response, instead we throw a NoneType Err:

In this example the --entrypoint blue doesn't exist.

> rsconnect deploy html html-multi-file/index.html --entrypoint blue -n dogfood -t "multiple html" -N
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 95, in wrapper
    result = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 1188, in deploy_html
    ce.validate_server()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/log.py", line 186, in wrapper
    result = method(self, *args, **kw)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/api.py", line 636, in make_bundle
    bundle = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 925, in make_html_bundle
    manifest = create_html_manifest(**locals())
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 890, in create_html_manifest
    excludes.extend(list_environment_dirs(deploy_dir))
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 792, in list_environment_dirs
    path = join(directory, name)
  File "/Users/kgartland/.pyenv/versions/3.8.2/lib/python3.8/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Internal error: expected str, bytes or os.PathLike object, not NoneType

@kgartland-rstudio
Copy link
Contributor

kgartland-rstudio commented Mar 9, 2023

When specifying two files in an html deployment, from outside the directory, we state:
No such file or directory, even when the file exists:

With this file structure:

-> tree html-multi-file/
html-multi-file/
├── index.html
├── package.json
├── rsconnect-python
│   └── html-multi-file.json
├── sandbox.config.json
└── second.html

From outside the directory:

> rsconnect deploy html html-multi-file/index.html html-multi-file/second.html -n dogfood -t "multiple html" -N
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: Unable to include the file second.html in the bundle: No such file or directory
Error: Unable to include the file second.html in the bundle: No such file or directory

When specifying two files in an html deployment, from inside the directory, we state:
Internal error: 'second.html' does not start with [PATH]:

> rsconnect deploy html index.html second.html -n dogfood -t "multiple html" -N
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: 'second.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'
Traceback (most recent call last):
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 95, in wrapper
    result = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 1188, in deploy_html
    ce.validate_server()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/log.py", line 186, in wrapper
    result = method(self, *args, **kw)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/api.py", line 636, in make_bundle
    bundle = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 941, in make_html_bundle
    return bundle.to_file()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 274, in to_file
    rel_path = Path(fp).relative_to(self.deploy_dir) if flatten_to_deploy_dir else None
  File "/Users/kgartland/.pyenv/versions/3.8.2/lib/python3.8/pathlib.py", line 899, in relative_to
    raise ValueError("{!r} does not start with {!r}"
ValueError: 'second.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'
Internal error: 'second.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'

The same error is presented, even when providing the full path of the second.html file as the error suggests:

> rsconnect deploy html index.html /Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file/second.html -n dogfood -t "multiple html" -N
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: 'second.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'
Traceback (most recent call last):
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 95, in wrapper
    result = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 1188, in deploy_html
    ce.validate_server()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/log.py", line 186, in wrapper
    result = method(self, *args, **kw)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/api.py", line 636, in make_bundle
    bundle = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 941, in make_html_bundle
    return bundle.to_file()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 274, in to_file
    rel_path = Path(fp).relative_to(self.deploy_dir) if flatten_to_deploy_dir else None
  File "/Users/kgartland/.pyenv/versions/3.8.2/lib/python3.8/pathlib.py", line 899, in relative_to
    raise ValueError("{!r} does not start with {!r}"
ValueError: 'second.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'
Internal error: 'second.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'

@bcwu
Copy link
Contributor Author

bcwu commented Mar 9, 2023

When specifying an entrypoint that doesn't exist we don't catch the error and give a reasonable response, instead we throw a NoneType Err:

fixed by f5a2146

When specifying two files in an html deployment, from outside the directory, we state: No such file or directory, even when the file exists:

With this file structure:

-> tree html-multi-file/
html-multi-file/
├── index.html
├── package.json
├── rsconnect-python
│   └── html-multi-file.json
├── sandbox.config.json
└── second.html

fixed by 2f8703a

@kgartland-rstudio
Copy link
Contributor

When specifying an entrypoint that doesn't exist we don't catch the error and give a reasonable response, instead we throw a NoneType Err:

fixed by f5a2146

When specifying two files in an html deployment, from outside the directory, we state: No such file or directory, even when the file exists:
With this file structure:

-> tree html-multi-file/
html-multi-file/
├── index.html
├── package.json
├── rsconnect-python
│   └── html-multi-file.json
├── sandbox.config.json
└── second.html

fixed by 2f8703a

These fixes look good.

@kgartland-rstudio
Copy link
Contributor

kgartland-rstudio commented Mar 10, 2023

Windows testing. When multiple files are in the target directory it fails with this error:

> rsconnect deploy html .\html\html-single-file\ -s https://rsc.radixu.com/ -k APIKEY
Validating server...    [OK]
Validating app mode...  [OK]
Making bundle ...       [ERROR]: 'html\\html-single-file\\nothin.html' is not in the subpath of 'C:\\Users\\User\\html\\html-single-file' OR one path is relative and the other is absolute.
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\rsconnect\main.py", line 95, in wrapper
    result = func(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\rsconnect\main.py", line 1190, in deploy_html
    .make_bundle(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\rsconnect\log.py", line 186, in wrapper
    result = method(self, *args, **kw)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\rsconnect\api.py", line 636, in make_bundle
    bundle = func(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\rsconnect\bundle.py", line 940, in make_html_bundle
    return bundle.to_file()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\rsconnect\bundle.py", line 274, in to_file
    rel_path = Path(fp).relative_to(self.deploy_dir) if flatten_to_deploy_dir else None
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\pathlib.py", line 818, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: 'html\\html-single-file\\nothin.html' is not in the subpath of 'C:\\Users\\User\\html\\html-single-file' OR one path is relative and the other is absolute.
Internal error: 'html\\html-single-file\\nothin.html' is not in the subpath of 'C:\\Users\\User\\html\\html-single-file' OR one path is relative and the other is absolute.

Directory structure:

    Directory: C:\Users\User\html\html-single-file


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         3/10/2023   6:58 AM                rsconnect-python
-a----         3/10/2023   6:58 AM            144 index.html
------         3/10/2023   6:58 AM              0 nothin.html

@kgartland-rstudio
Copy link
Contributor

When specifying an entrypoint where multiple html files exist...

  1. do we expect to require the path to the file? or just the file name itself? Since we're giving the path to the deployment directory, I would expect that the path wouldn't be required in the entrypoint arg.
> rsconnect deploy html bundles/html-multi-file/ --entrypoint second.html -n dogfood
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: Entrypoint second.html does not exist.
Error: Entrypoint second.html does not exist.

Directory structure:

> tree bundles/html-multi-file/
bundles/html-multi-file/
├── index.html
├── package.json
├── rsconnect-python
│   └── html-multi-file.json
├── sandbox.config.json
└── second.html
  1. When you do specify the full path in the entrypoint arg, it fails:
> rsconnect deploy html bundles/html-multi-file/ --entrypoint bundles/html-multi-file/second.html -n dogfood
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: 'bundles/html-multi-file/index.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'
Traceback (most recent call last):
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 95, in wrapper
    result = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/main.py", line 1188, in deploy_html
    ce.validate_server()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/log.py", line 186, in wrapper
    result = method(self, *args, **kw)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/api.py", line 636, in make_bundle
    bundle = func(*args, **kwargs)
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 940, in make_html_bundle
    return bundle.to_file()
  File "/Users/kgartland/.pyenv/versions/3.8.2/envs/rsconnect-tag/lib/python3.8/site-packages/rsconnect/bundle.py", line 274, in to_file
    rel_path = Path(fp).relative_to(self.deploy_dir) if flatten_to_deploy_dir else None
  File "/Users/kgartland/.pyenv/versions/3.8.2/lib/python3.8/pathlib.py", line 899, in relative_to
    raise ValueError("{!r} does not start with {!r}"
ValueError: 'bundles/html-multi-file/index.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'
Internal error: 'bundles/html-multi-file/index.html' does not start with '/Users/kgartland/work/connect/test/rsconnect-python/bundles/html-multi-file'

@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch from 8e1f533 to dc011c0 Compare March 10, 2023 16:28
remove create_abspath_list
@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch from dc011c0 to 0415875 Compare March 10, 2023 16:32
@bcwu
Copy link
Contributor Author

bcwu commented Mar 10, 2023

Windows testing. When multiple files are in the target directory it fails with this error:

> rsconnect deploy html .\html\html-single-file\ -s https://rsc.radixu.com/ -k APIKEY

fixed by 0415875

When specifying an entrypoint where multiple html files exist...

1. do we expect to require the path to the file? or just the file name itself?  Since we're giving the path to the deployment directory, I would expect that the path wouldn't be required in the entrypoint arg.

This depends on where you are deploying the files. If you are outside the folder, you have to give it the full path.

2. When you _do_ specify the full path in the entrypoint arg, it fails:

fixed by 0415875

@kgartland-rstudio
Copy link
Contributor

It looks like this part is still broken:

do we expect to require the path to the file? or just the file name itself? Since we're giving the path to the deployment directory, I would expect that the path wouldn't be required in the entrypoint arg.

> rsconnect deploy html bundles/html-multi-file/ --entrypoint second.html -n dogfood
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: Entrypoint second.html does not exist.
Error: Entrypoint second.html does not exist.

@bcwu
Copy link
Contributor Author

bcwu commented Mar 10, 2023

It looks like this part is still broken:

do we expect to require the path to the file? or just the file name itself? Since we're giving the path to the deployment directory, I would expect that the path wouldn't be required in the entrypoint arg.

> rsconnect deploy html bundles/html-multi-file/ --entrypoint second.html -n dogfood
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: Entrypoint second.html does not exist.
Error: Entrypoint second.html does not exist.

The full path has to be specified for the entrypoint if you are outside the folder. So in this case:

rsconnect deploy html bundles/html-multi-file/ --entrypoint bundles/html-multi-file/second.html -n dogfood

The other way is to do relative deploy, like so:

cd html bundles/html-multi-file/
rsconnect deploy html ./ --entrypoint second.html -n dogfood

@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch from 4b4b312 to 43b49df Compare March 10, 2023 17:06
@kgartland-rstudio
Copy link
Contributor

It looks like this part is still broken:

do we expect to require the path to the file? or just the file name itself? Since we're giving the path to the deployment directory, I would expect that the path wouldn't be required in the entrypoint arg.

> rsconnect deploy html bundles/html-multi-file/ --entrypoint second.html -n dogfood
Validating server... 	[OK]
Validating app mode... 	[OK]
Making bundle ... 	[ERROR]: Entrypoint second.html does not exist.
Error: Entrypoint second.html does not exist.

The full path has to be specified for the entrypoint if you are outside the folder. So in this case:

rsconnect deploy html bundles/html-multi-file/ --entrypoint bundles/html-multi-file/second.html -n dogfood

The other way is to do relative deploy, like so:

cd html bundles/html-multi-file/
rsconnect deploy html ./ --entrypoint second.html -n dogfood

I realize it works as expected when you're in the directory you're trying to deploy. However that's not the way other content-types work. Are we fine with deviating away from how other deployment types work for html using --entrypoint?

We'll at least have to document around that.

@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch 3 times, most recently from 7b5c7db to 2740862 Compare March 10, 2023 17:55
@bcwu
Copy link
Contributor Author

bcwu commented Mar 10, 2023

We'll at least have to document around that.

Added documentation on the deploy html behavior in the changelog

Let me know if there's anything that's missed.

@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch from 2740862 to 82010ce Compare March 10, 2023 18:47
@kgartland-rstudio
Copy link
Contributor

Testing on Windows is complete. I think we're good to merge 👍

@bcwu bcwu force-pushed the bcwu-refactor-deploy-html branch from 82010ce to 07d182c Compare March 10, 2023 18:57
@bcwu bcwu merged commit 5b1ea3c into master Mar 10, 2023
@bcwu bcwu deleted the bcwu-refactor-deploy-html branch March 10, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants