Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conda config warning docs/message; add duration log for actions #823

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import subprocess
import tempfile
import time
import typing
import uuid

Expand All @@ -27,8 +28,14 @@ def wrapper(*args, stdout=None, stderr=None, **kwargs):
# enter temporary directory
stack.enter_context(utils.chdir(tmpdir))

start_time = time.monotonic()

# run function and store result
action_context.result = f(action_context, *args, **kwargs)
action_context.log.info(
f"Action {f.__name__} completed in {time.monotonic() - start_time:.3f} s."
)

return action_context

return wrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ def action_solve_lockfile(
with environment_filename.open("w") as f:
json.dump(specification.dict(), f)

context.log.info(
"Note that the output of `conda config --show` displayed below only reflects "
"settings in the conda configuration file, which might be overridden by "
"variables required to be set by conda-store via the environment. Overridden "
f"settings: CONDA_FLAGS={conda_flags}"
Comment on lines +31 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting three distinct messages from this paragraph:

  1. conda config shows settings in Conda configuration file
  2. Some of the settings shown may therefore not be accurate because they have been overridden by Conda Store.
  3. Here are some (all?) of the settings that have been overridden in Conda Store.

Is that accurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these were the three things I was trying to convey. As far as I know these are all of the overridden settings as well.

)

# The info command can be used with either mamba or conda
logged_command(context, [conda_command, "info"])
# The config command is not supported by mamba
Expand Down
11 changes: 8 additions & 3 deletions conda-store-server/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@


def test_action_decorator():
"""Test that the action decorator captures stdout/stderr and logs correctly."""

@action.action
def test_function(context):
print("stdout")
Expand Down Expand Up @@ -48,10 +50,13 @@ def test_function(context):
return pathlib.Path.cwd()

context = test_function()
assert (
context.stdout.getvalue()
== "stdout\nstderr\nsubprocess\nsubprocess_stdout\nsubprocess_stderr\nlog\n"

stdout = context.stdout.getvalue()
assert stdout.startswith(
"stdout\nstderr\nsubprocess\nsubprocess_stdout\nsubprocess_stderr\nlog\n"
)
assert re.search(r"Action test_function completed in \d+\.\d+ s.\n$", stdout)

assert context.stderr.getvalue() == "subprocess_stderr_no_redirect\n"
# test that action direction is not the same as outside function
assert context.result != pathlib.Path.cwd()
Expand Down
12 changes: 12 additions & 0 deletions docusaurus-docs/conda-store/explanations/conda-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ could be updated the next minute the same solve for the same

<!-- External links -->
[conda-docs-environments]: https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html

## Understanding `conda config` and how it relates to conda-store

Because conda-store needs to configure some parts of conda without modifying
the user's conda configuration file, internally conda-store sets some conda
configuration variables using environment variables. The impact of this is that
if a user tries to print their conda configuration with `conda config`, some of
the configuration settings displayed by that command will not reflect the values
that are actually used by conda-store. In particular, `conda-store` internally
sets `CONDA_FLAGS=--strict-channel-priority`, overriding the channel priority in
the conda configuration file. Please keep this in mind when using `conda config`
to inspect your conda configuration and when viewing the build logs.
Loading