Skip to content

Commit

Permalink
remove rename comm and associated settings/tests (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
shouples authored Jan 31, 2023
1 parent 777aa9b commit bbde049
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 136 deletions.
1 change: 0 additions & 1 deletion src/dx/comms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .assignment import *
from .rename import *
from .resample import *
64 changes: 0 additions & 64 deletions src/dx/comms/rename.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/dx/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class Settings(BaseSettings):

# controls dataframe variable tracking, hashing, and storing in sqlite
ENABLE_DATALINK: bool = True
ENABLE_RENAMER: bool = True
ENABLE_ASSIGNMENT: bool = True

NUM_PAST_SAMPLES_TRACKED: int = 3
Expand Down Expand Up @@ -246,7 +245,6 @@ def enable_disable_comms(

comm_setting_targets = {
"ENABLE_DATALINK": ("datalink_resample", comms.resample.resampler),
"ENABLE_RENAMER": ("rename", comms.rename.renamer),
"ENABLE_ASSIGNMENT": ("datalink_assignment", comms.assignment.dataframe_assignment),
}
if setting_name not in comm_setting_targets:
Expand Down
69 changes: 0 additions & 69 deletions tests/test_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from IPython.terminal.interactiveshell import TerminalInteractiveShell

from dx.comms.assignment import handle_assignment_comm
from dx.comms.rename import handle_renaming_comm
from dx.comms.resample import handle_resample_comm
from dx.types.filters import DEXFilterSettings, DEXResampleMessage

Expand Down Expand Up @@ -52,74 +51,6 @@ def test_resample_skipped(self, mocker):
mock_handle_resample.assert_not_called()


class TestRenameComm:
def test_rename_handled(
self,
get_ipython: TerminalInteractiveShell,
sample_dataframe: pd.DataFrame,
):
"""
Test that a rename comm is handled properly when
`old_name` and `new_name` are passed in the comm message
data, and `old_name` exists in the kernel namespace as a
pandas DataFrame. During a rename operation, the old
variable should be removed from the kernel namespace as wel.
"""
msg = {
"content": {
"data": {
"old_name": "old_df",
"new_name": "new_df",
}
}
}
get_ipython.user_ns["old_df"] = sample_dataframe
handle_renaming_comm(msg, ipython_shell=get_ipython)
assert "new_df" in get_ipython.user_ns.keys()
assert "old_df" not in get_ipython.user_ns.keys()

def test_rename_skipped_missing_values(
self,
get_ipython: TerminalInteractiveShell,
):
"""
Test that a rename comm is skipped if `old_name` or `new_name`
aren't both present in the comm message.
"""
msg = {
"content": {
"data": {
"new_name": "new_df",
}
}
}
handle_renaming_comm(msg, ipython_shell=get_ipython)
assert "new_df" not in get_ipython.user_ns.keys()

def test_rename_non_dataframes(
self,
get_ipython: TerminalInteractiveShell,
):
"""
Test that a rename comm is also works if non-dataframe is referenced.
"""
msg = {
"content": {
"data": {
"old_name": "old_var",
"new_name": "new_var",
}
}
}
the_string = "I am not a dataframe; I am a string."
get_ipython.user_ns["old_var"] = the_string
handle_renaming_comm(msg, ipython_shell=get_ipython)
assert (
"new_var" in get_ipython.user_ns.keys() and get_ipython.user_ns["new_var"] == the_string
)
assert "old_var" not in get_ipython.user_ns.keys()


class TestAssignmentComm:
def test_assignment_handled(
self,
Expand Down

0 comments on commit bbde049

Please sign in to comment.