rename eden.thrift Python module to eden.thrift.legacy

Summary:
The Python 2-and-3 Thrift API is sort of deprecated and does not
handle binary data in `binary` fields. In advance of migrating to the
modern Python 3 API, remane eden.thrift to eden.thrift.legacy.

Reviewed By: fanzeyi

Differential Revision: D21889697

fbshipit-source-id: a745ee8977999acbfb383a4edebe81d8deb1734e
This commit is contained in:
Chad Austin 2020-06-09 10:07:15 -07:00 committed by Facebook GitHub Bot
parent 18e40104ab
commit 7e4835f677
14 changed files with 27 additions and 48 deletions

View File

@ -21,9 +21,9 @@ import typing
from pathlib import Path
from typing import Any, Dict, List, Mapping, Optional, Set, Tuple, Type, Union, cast
import eden.thrift
import facebook.eden.ttypes as eden_ttypes
import toml
from eden.thrift.legacy import EdenClient, create_thrift_client
from . import configinterpolator, configutil, telemetry, util, version
from .util import (
@ -345,10 +345,8 @@ class EdenInstance:
"""Return the paths of the set mount points stored in config.json"""
return [str(path) for path in self._get_directory_map().keys()]
def get_thrift_client(self, timeout=None) -> eden.thrift.EdenClient:
return eden.thrift.create_thrift_client(
eden_dir=str(self._config_dir), timeout=timeout
)
def get_thrift_client(self, timeout=None) -> EdenClient:
return create_thrift_client(eden_dir=str(self._config_dir), timeout=timeout)
def get_checkout_info(self, path: Union[Path, str]) -> collections.OrderedDict:
"""

View File

@ -17,11 +17,10 @@ import typing
from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Tuple, Type
import eden.thrift
import thrift.transport
from eden.fs.cli.telemetry import TelemetrySample
from eden.fs.cli.util import check_health_using_lockfile, wait_for_instance_healthy
from eden.thrift import EdenNotRunningError
from eden.thrift.legacy import EdenClient, EdenNotRunningError
from facebook.eden import EdenService
from facebook.eden.ttypes import GlobParams, MountInfo as ThriftMountInfo, MountState
from fb303_core.ttypes import fb303_status
@ -1340,7 +1339,7 @@ def stop_aux_processes_for_path(repo_path: str) -> None:
unmount_redirections_for_path(repo_path)
def stop_aux_processes(client: eden.thrift.EdenClient) -> None:
def stop_aux_processes(client: EdenClient) -> None:
"""Tear down processes that will hold onto file handles and prevent shutdown
for all mounts"""

View File

@ -18,8 +18,8 @@ import typing
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, List, Optional, TypeVar, Union
import eden.thrift
import thrift.transport
from eden.thrift.legacy import EdenClient, EdenNotRunningError
from facebook.eden.ttypes import TreeInodeDebugInfo
from fb303_core.ttypes import fb303_status
from thrift import Thrift
@ -163,7 +163,7 @@ def _create_dead_health_status() -> HealthStatus:
def check_health(
get_client: Callable[..., eden.thrift.EdenClient],
get_client: Callable[..., EdenClient],
config_dir: Path,
timeout: Optional[float] = None,
) -> HealthStatus:
@ -191,10 +191,7 @@ def check_health(
assert status_value is not None
status = status_value
uptime = info.uptime
except (
eden.thrift.EdenNotRunningError,
thrift.transport.TTransport.TTransportException,
):
except (EdenNotRunningError, thrift.transport.TTransport.TTransportException):
# It is possible that the edenfs process is running, but the Thrift
# server is not running. This could be during the startup, shutdown,
# or takeover of the edenfs process. As a backup to requesting the
@ -213,7 +210,7 @@ def check_health(
def wait_for_daemon_healthy(
proc: subprocess.Popen,
config_dir: Path,
get_client: Callable[..., eden.thrift.EdenClient],
get_client: Callable[..., EdenClient],
timeout: float,
exclude_pid: Optional[int] = None,
) -> HealthStatus:

View File

@ -1,11 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import, division, print_function, unicode_literals
from eden.thrift.client import EdenClient, EdenNotRunningError, create_thrift_client
__all__ = ["EdenClient", "EdenNotRunningError", "create_thrift_client"]

View File

@ -7,7 +7,7 @@
import time
from pathlib import Path
from eden.thrift import EdenClient
from eden.thrift.legacy import EdenClient
from facebook.eden.eden_config.ttypes import (
ConfigReloadBehavior,
ConfigSource,

View File

@ -7,7 +7,7 @@
import os
from typing import Iterable
import eden.thrift
from eden.thrift.legacy import EdenClient
from facebook.eden.ttypes import TimeSpec
from . import edenclient
@ -25,7 +25,7 @@ class EdenServerInspector(object):
self._eden = eden
self._mount_point = mount_point
def create_thrift_client(self) -> eden.thrift.EdenClient:
def create_thrift_client(self) -> EdenClient:
return self._eden.get_thrift_client()
def unload_inode_for_path(self, path: str = "") -> None:

View File

@ -17,8 +17,8 @@ from pathlib import Path
from types import TracebackType
from typing import Any, Dict, List, Optional, Union, cast
import eden.thrift
from eden.fs.cli import util
from eden.thrift.legacy import EdenClient, create_thrift_client
from facebook.eden.ttypes import MountState
from .find_executables import FindExe
@ -124,8 +124,8 @@ class EdenFS(object):
return
self.shutdown()
def get_thrift_client(self, timeout=None) -> eden.thrift.EdenClient:
return eden.thrift.create_thrift_client(str(self._eden_dir), timeout=timeout)
def get_thrift_client(self, timeout=None) -> EdenClient:
return create_thrift_client(str(self._eden_dir), timeout=timeout)
def run_cmd(
self,
@ -469,7 +469,7 @@ class EdenFS(object):
return results
def get_mount_state(
self, mount: pathlib.Path, client: Optional[eden.thrift.EdenClient] = None
self, mount: pathlib.Path, client: Optional[EdenClient] = None
) -> Optional[MountState]:
"""
Query edenfs over thrift for the state of the specified mount.

View File

@ -11,7 +11,7 @@ import signal
import subprocess
import typing
import eden.thrift
from eden.thrift.legacy import create_thrift_client
from .find_executables import FindExe
@ -87,5 +87,5 @@ class FakeEdenFS(typing.ContextManager[int]):
def get_fake_edenfs_argv(eden_dir: pathlib.Path) -> typing.List[str]:
with eden.thrift.create_thrift_client(str(eden_dir)) as client:
with create_thrift_client(str(eden_dir)) as client:
return client.getDaemonInfo().commandLine

View File

@ -29,7 +29,7 @@ from typing import (
import eden.config
from eden.test_support.testcase import EdenTestCaseBase
from eden.thrift import EdenClient
from eden.thrift.legacy import EdenClient
from . import blacklist, edenclient, gitrepo, hgrepo, repobase
from .find_executables import FindExe

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
@ -12,7 +11,7 @@ from pathlib import Path
from typing import Optional, Set
from eden.fs.cli.util import poll_until
from eden.thrift import EdenClient, EdenNotRunningError
from eden.thrift.legacy import EdenClient, EdenNotRunningError
from facebook.eden.ttypes import (
EdenError,
EdenErrorType,

View File

@ -9,11 +9,10 @@ import sys
import typing
from typing import Optional
import eden.thrift
import eden.thrift.client
import pexpect
from eden.fs.cli.config import EdenInstance
from eden.fs.cli.util import HealthStatus
from eden.thrift.legacy import SOCKET_PATH, EdenClient, create_thrift_client
from .lib.find_executables import FindExe
from .lib.pexpect import PexpectAssertionMixin, PexpectSpawnType, pexpect_spawn
@ -77,8 +76,8 @@ class RestartTest(RestartTestBase, PexpectAssertionMixin):
p.wait()
self.assertEqual(p.exitstatus, 0)
def _get_thrift_client(self) -> eden.thrift.EdenClient:
return eden.thrift.create_thrift_client(str(self.eden_dir))
def _get_thrift_client(self) -> EdenClient:
return create_thrift_client(str(self.eden_dir))
def test_restart(self) -> None:
self._start_fake_edenfs()
@ -210,9 +209,7 @@ class RestartTest(RestartTestBase, PexpectAssertionMixin):
# Rename the thrift socket so that "eden restart" will not be able to
# communicate with the existing daemon.
(self.eden_dir / eden.thrift.client.SOCKET_PATH).rename(
self.eden_dir / "old.socket"
)
(self.eden_dir / SOCKET_PATH).rename(self.eden_dir / "old.socket")
# "eden restart" should not restart if it cannot confirm the current health of
# edenfs.

View File

@ -15,7 +15,7 @@ from typing import Dict, Optional
import pexpect
from eden.fs.cli.util import get_pid_using_lockfile, poll_until
from eden.thrift import EdenClient
from eden.thrift.legacy import EdenClient
from facebook.eden.ttypes import FaultDefinition, UnblockFaultArg
from fb303_core.ttypes import fb303_status
@ -246,7 +246,7 @@ class TakeoverTest(testcase.EdenRepoTest):
)
def test_takeover_preserves_inode_numbers_for_open_nonmaterialized_files(
self
self,
) -> None:
hello = os.path.join(self.mount, "tree/hello")

View File

@ -54,7 +54,7 @@ if sys.version_info < (2, 7, 6):
# loaded, and only throwing ImportError later when you actually try to use
# them.
with demandimport.deactivated():
import eden.thrift as eden_thrift_module
import eden.thrift.legacy as eden_thrift_module
import facebook.eden.ttypes as eden_ttypes
create_thrift_client = eden_thrift_module.create_thrift_client