Skip to content

Commit

Permalink
Merge pull request #500 from rstudio/sagerb-remove-conda
Browse files Browse the repository at this point in the history
Remove Conda flag
  • Loading branch information
sagerb authored Oct 18, 2023
2 parents 7d81048 + dde06a5 commit a1134fd
Show file tree
Hide file tree
Showing 24 changed files with 272 additions and 502 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ coverage.xml

# Temporary dev files
vetiver-testing/rsconnect_api_keys.json
/pip-wheel-metadata/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
new level. Currently this will cause filenames to be logged as they are added to
a bundle. To enable maximum verbosity (debug level), use `-vv`.

### Changed
- Removing experimental support for Conda. Connect does not support restoring Conda environments.

## [1.20.0] - 2023-09-11

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@


def pytest_addoption(parser):
parser.addoption(
"--vetiver", action="store_true", default=False, help="run vetiver tests"
)
parser.addoption("--vetiver", action="store_true", default=False, help="run vetiver tests")


def pytest_configure(config):
config.addinivalue_line("markers", "vetiver: test for vetiver interaction")


def pytest_collection_modifyitems(config, items):
if config.getoption("--vetiver"):
return
Expand Down
4 changes: 3 additions & 1 deletion docs/patch_admonitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import sys


def rewrite(gh_admonition, mkdocs_admonition, lines):
for i in range(len(lines)):
line = lines[i]
Expand All @@ -35,7 +36,7 @@ def rewrite(gh_admonition, mkdocs_admonition, lines):
# The start of the GitHub admonition MUST be on its own line.
if gh_admonition == line.rstrip():
lines[i] = f"!!! { mkdocs_admonition }\n"
for j in range(i+1, len(lines)):
for j in range(i + 1, len(lines)):
if lines[j].startswith("> "):
text = lines[j][2:]
lines[j] = f" { text }"
Expand All @@ -44,6 +45,7 @@ def rewrite(gh_admonition, mkdocs_admonition, lines):
break
return lines


lines = sys.stdin.readlines()

lines = rewrite("> **Note**", "note", lines)
Expand Down
1 change: 0 additions & 1 deletion mock_connect/mock_connect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def python_settings():
return {
"installations": [{"version": v}],
"api_enabled": True,
"conda_enabled": False,
}


Expand Down
4 changes: 3 additions & 1 deletion my-shiny-app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
ui.output_text_verbatim("txt", placeholder=True),
)


def server(input, output, session):
@output()
@render_text()
def txt():
return f"n*2 is {input.n() * 2}"

app = App(app_ui, server)

app = App(app_ui, server)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
requires = ["setuptools>=61", "wheel", "setuptools_scm[toml]>=3.4"]

[tool.black]
line-length = 120
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pytest
pytest-cov
pytest-mypy
semver>=2.0.0,<3.0.0
setuptools>=61
setuptools_scm
six>=1.14.0
toml
Expand Down
98 changes: 44 additions & 54 deletions rsconnect/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def which_python(python, env=os.environ):
def inspect_environment(
python, # type: str
directory, # type: str
conda_mode=False, # type: bool
force_generate=False, # type: bool
check_output=subprocess.check_output, # type: typing.Callable
):
Expand All @@ -142,8 +141,6 @@ def inspect_environment(
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
flags = []
if conda_mode:
flags.append("c")
if force_generate:
flags.append("f")
args = [python, "-m", "rsconnect.environment"]
Expand Down Expand Up @@ -250,10 +247,9 @@ def gather_server_details(connect_server):
and the versions of Python installed there.
:param connect_server: the Connect server information.
:return: a three-entry dictionary. The key 'connect' will refer to the version
:return: a two-entry dictionary. The key 'connect' will refer to the version
of Connect that was found. The key `python` will refer to a sequence of version
strings for all the versions of Python that are installed. The key `conda` will
refer to data about whether Connect is configured to support Conda environments.
strings for all the versions of Python that are installed.
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)

Expand All @@ -264,28 +260,15 @@ def _to_sort_key(text):
server_settings = api.verify_server(connect_server)
python_settings = api.get_python_info(connect_server)
python_versions = sorted([item["version"] for item in python_settings["installations"]], key=_to_sort_key)
conda_settings = {"supported": python_settings["conda_enabled"] if "conda_enabled" in python_settings else False}
return {
"connect": server_settings["version"],
"python": {
"api_enabled": python_settings["api_enabled"] if "api_enabled" in python_settings else False,
"versions": python_versions,
},
"conda": conda_settings,
}


def is_conda_supported_on_server(connect_details):
"""
Returns whether or not conda is supported on a Connect server.
:param connect_details: details about a Connect server as returned by gather_server_details()
:return: boolean True if supported, False otherwise
:error: Conda is not supported on the target server. Try deploying without requesting Conda.
"""
return connect_details.get("conda", {}).get("supported", False)


def _make_deployment_name(remote_server: api.TargetableServer, title: str, force_unique: bool) -> str:
"""
Produce a name for a deployment based on its title. It is assumed that the
Expand Down Expand Up @@ -615,7 +598,6 @@ def deploy_jupyter_notebook(
title: str,
static: bool,
python: str,
conda_mode: bool,
force_generate: bool,
log_callback: typing.Callable,
hide_all_input: bool,
Expand All @@ -638,8 +620,6 @@ def deploy_jupyter_notebook(
:param static: a flag noting whether the notebook should be deployed as a static
HTML page or as a render-able document with sources. Previous default = False.
:param python: the optional name of a Python executable, previous default = None.
:param conda_mode: use conda to build an environment.yml instead of conda, when
conda is not supported on Posit Connect (version<=1.8.0). Previous default = False.
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists. Previous default = False.
:param log_callback: the callback to use to write the log to. If this is None
Expand Down Expand Up @@ -687,7 +667,7 @@ def deploy_jupyter_notebook(
_warn_on_ignored_manifest(base_dir)
_warn_if_no_requirements_file(base_dir)
_warn_if_environment_directory(base_dir)
python, environment = get_python_env_info(file_name, python, conda_mode, force_generate)
python, environment = get_python_env_info(file_name, python, force_generate)

if force_generate:
_warn_on_ignored_requirements(base_dir, environment.filename)
Expand Down Expand Up @@ -747,7 +727,6 @@ def deploy_app(
app_id: str = None,
title: str = None,
python: str = None,
conda_mode: bool = False,
force_generate: bool = False,
verbose: bool = None,
directory: str = None,
Expand Down Expand Up @@ -791,7 +770,6 @@ def deploy_app(
directory,
force_generate,
python,
conda_mode,
)

ce = RSConnectExecutor(**kwargs)
Expand Down Expand Up @@ -826,7 +804,6 @@ def deploy_python_api(
app_id: int,
title: str,
python: str,
conda_mode: bool,
force_generate: bool,
log_callback: typing.Callable,
image: str = None,
Expand All @@ -847,8 +824,6 @@ def deploy_python_api(
:param title: an optional title for the deploy. If this is not provided, one will
be generated. Previous default = None.
:param python: the optional name of a Python executable. Previous default = None.
:param conda_mode: use conda to build an environment.yml instead of conda, when
conda is not supported on Posit Connect (version<=1.8.0). Previous default = False.
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists. Previous default = False.
:param log_callback: the callback to use to write the log to. If this is None
Expand Down Expand Up @@ -897,8 +872,7 @@ def deploy_python_fastapi(
:param title: an optional title for the deploy. If this is not provided, one will
be generated. Previous default = None.
:param python: the optional name of a Python executable. Previous default = None.
:param conda_mode: use conda to build an environment.yml instead of conda, when
conda is not supported on Posit Connect (version<=1.8.0). Previous default = False.
:param conda_mode: depricated parameter, included for compatibility. Ignored.
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists. Previous default = False.
:param log_callback: the callback to use to write the log to. If this is None
Expand Down Expand Up @@ -926,7 +900,6 @@ def deploy_python_shiny(
app_id=None,
title=None,
python=None,
conda_mode=False,
force_generate=False,
log_callback=None,
):
Expand All @@ -944,8 +917,6 @@ def deploy_python_shiny(
:param title: an optional title for the deploy. If this is not provided, ne will
be generated.
:param python: the optional name of a Python executable.
:param conda_mode: use conda to build an environment.yml
instead of conda, when conda is not supported on Posit Connect (version<=1.8.0).
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists.
:param log_callback: the callback to use to write the log to. If this is None
Expand All @@ -968,7 +939,6 @@ def deploy_dash_app(
app_id: int,
title: str,
python: str,
conda_mode: bool,
force_generate: bool,
log_callback: typing.Callable,
image: str = None,
Expand All @@ -989,8 +959,6 @@ def deploy_dash_app(
:param title: an optional title for the deploy. If this is not provided, one will
be generated. Previous default = None.
:param python: the optional name of a Python executable. Previous default = None.
:param conda_mode: use conda to build an environment.yml instead of conda, when
conda is not supported on Posit Connect (version<=1.8.0). Previous default = False.
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists. Previous default = False.
:param log_callback: the callback to use to write the log to. If this is None
Expand Down Expand Up @@ -1018,7 +986,6 @@ def deploy_streamlit_app(
app_id: int,
title: str,
python: str,
conda_mode: bool,
force_generate: bool,
log_callback: typing.Callable,
image: str = None,
Expand All @@ -1039,8 +1006,6 @@ def deploy_streamlit_app(
:param title: an optional title for the deploy. If this is not provided, one will
be generated. Previous default = None.
:param python: the optional name of a Python executable. Previous default = None.
:param conda_mode: use conda to build an environment.yml instead of conda, when
conda is not supported on Posit Connect (version<=1.8.0). Previous default = False.
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists. Previous default = False.
:param log_callback: the callback to use to write the log to. If this is None
Expand Down Expand Up @@ -1068,7 +1033,6 @@ def deploy_bokeh_app(
app_id: int,
title: str,
python: str,
conda_mode: bool,
force_generate: bool,
log_callback: typing.Callable,
image: str = None,
Expand All @@ -1089,8 +1053,6 @@ def deploy_bokeh_app(
:param title: an optional title for the deploy. If this is not provided, one will
be generated. Previous default = None.
:param python: the optional name of a Python executable. Previous default = None.
:param conda_mode: use conda to build an environment.yml instead of conda, when
conda is not supported on Posit Connect (version<=1.8.0). Previous default = False.
:param force_generate: force generating "requirements.txt" or "environment.yml",
even if it already exists. Previous default = False.
:param log_callback: the callback to use to write the log to. If this is None
Expand Down Expand Up @@ -1284,8 +1246,9 @@ def create_api_deployment_bundle(
if app_mode is None:
app_mode = AppModes.PYTHON_API

return make_api_bundle(directory, entry_point, app_mode, environment, extra_files, excludes,
image, env_management_py, env_management_r)
return make_api_bundle(
directory, entry_point, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
)


def create_quarto_deployment_bundle(
Expand Down Expand Up @@ -1322,8 +1285,17 @@ def create_quarto_deployment_bundle(
if app_mode is None:
app_mode = AppModes.STATIC_QUARTO

return make_quarto_source_bundle(file_or_directory, inspect, app_mode, environment, extra_files, excludes,
image, env_management_py, env_management_r)
return make_quarto_source_bundle(
file_or_directory,
inspect,
app_mode,
environment,
extra_files,
excludes,
image,
env_management_py,
env_management_r,
)


def deploy_bundle(
Expand Down Expand Up @@ -1431,8 +1403,15 @@ def create_notebook_manifest_and_environment_file(
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
if (
not write_notebook_manifest_json(
entry_point_file, environment, app_mode, extra_files, hide_all_input, hide_tagged_input,
image, env_management_py, env_management_r,
entry_point_file,
environment,
app_mode,
extra_files,
hide_all_input,
hide_tagged_input,
image,
env_management_py,
env_management_r,
)
or force
):
Expand Down Expand Up @@ -1485,8 +1464,9 @@ def write_notebook_manifest_json(
if app_mode == AppModes.UNKNOWN:
raise RSConnectException('Could not determine the app mode from "%s"; please specify one.' % extension)

manifest_data = make_source_manifest(app_mode, environment, file_name, None,
image, env_management_py, env_management_r)
manifest_data = make_source_manifest(
app_mode, environment, file_name, None, image, env_management_py, env_management_r
)
manifest_add_file(manifest_data, file_name, directory)
manifest_add_buffer(manifest_data, environment.filename, environment.contents)

Expand Down Expand Up @@ -1533,8 +1513,17 @@ def create_api_manifest_and_environment_file(
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
if (
not write_api_manifest_json(directory, entry_point, environment, app_mode, extra_files, excludes,
image, env_management_py, env_management_r)
not write_api_manifest_json(
directory,
entry_point,
environment,
app_mode,
extra_files,
excludes,
image,
env_management_py,
env_management_r,
)
or force
):
write_environment_file(environment, directory)
Expand Down Expand Up @@ -1573,8 +1562,9 @@ def write_api_manifest_json(
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
extra_files = validate_extra_files(directory, extra_files)
manifest, _ = make_api_manifest(directory, entry_point, app_mode, environment, extra_files, excludes,
image, env_management_py, env_management_r)
manifest, _ = make_api_manifest(
directory, entry_point, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
)
manifest_path = join(directory, "manifest.json")

write_manifest_json(manifest_path, manifest)
Expand Down
Loading

0 comments on commit a1134fd

Please sign in to comment.