Skip to content

Commit

Permalink
fix: set appmap_dir, language in default config
Browse files Browse the repository at this point in the history
Make sure `appmap_dir` and `language` are set the default configuration,
and therefore in the generated appmap.yml. The IDE extensions will
perform better as a result.
  • Loading branch information
apotterri committed Dec 9, 2022
1 parent 845cc23 commit 7383c18
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
18 changes: 17 additions & 1 deletion appmap/_implementation/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,23 @@ def labels(self):

@property
def default(self):
return {"name": self.default_name, "packages": self.default_packages}
ret = {
"name": self.default_name,
"language": "python",
"packages": self.default_packages,
}
env = Env.current
output_dir = env.output_dir
root_dir = env.root_dir
try:
ret["appmap_dir"] = str(output_dir.relative_to(root_dir))
except ValueError:
# The only way we can get here is if APPMAP_OUTPUT_DIR is set, and we've already logged
# a warning. (Note that PurePath.is_relative_to wasn't added till 3.9, so it can't be
# used here.)
pass

return ret

@property
def default_name(self):
Expand Down
11 changes: 9 additions & 2 deletions appmap/_implementation/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ def __init__(self, env=None, cwd=None):
self._root_dir = str(self._cwd) + "/"
self._root_dir_len = len(self._root_dir)

output_dir = Path(self.get("APPMAP_OUTPUT_DIR", "tmp/appmap"))
self._output_dir = output_dir.resolve()
logger = logging.getLogger(__name__)
# The user shouldn't set APPMAP_OUTPUT_DIR, but some tests depend on being able to use it.
appmap_output_dir = self.get("APPMAP_OUTPUT_DIR", None)
if appmap_output_dir is not None:
logger.warning("Setting APPMAP_OUTPUT_DIR is not supported")
else:
appmap_output_dir = "tmp/appmap"

self._output_dir = Path(appmap_output_dir).resolve()

def set(self, name, value):
self._env[name] = value
Expand Down
1 change: 1 addition & 0 deletions appmap/test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def check_default_config(self, expected_name):
{"path": "package"},
{"path": "test"},
]
assert default_config.default["appmap_dir"] == "tmp/appmap"


class TestDefaultConfig(DefaultHelpers):
Expand Down

0 comments on commit 7383c18

Please sign in to comment.