Skip to content

Commit

Permalink
remove changes applied to legacy client
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Sadkowski committed Jan 11, 2024
1 parent 43809b1 commit db2d036
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/neptune/legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
]


import logging
import os
import threading

from neptune.common.utils import assure_project_qualified_name
from neptune.internal.utils.logger import get_logger
from neptune.legacy import (
constants,
envs,
Expand All @@ -72,7 +72,7 @@

__lock = threading.RLock()

_logger = get_logger()
_logger = logging.getLogger(__name__)

"""Access Neptune as an anonymous user.
You can pass this value as api_token during init() call, either by an environment variable or passing it directly
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
import base64
import logging
import traceback

import pandas as pd
Expand All @@ -26,7 +27,6 @@
is_float,
is_nan_or_inf,
)
from neptune.internal.utils.logger import get_logger
from neptune.legacy.api_exceptions import (
ChannelDoesNotExist,
ExperimentAlreadyFinished,
Expand All @@ -46,7 +46,7 @@
from neptune.legacy.internal.utils.deprecation import legacy_client_deprecation
from neptune.legacy.internal.utils.image import get_image_content

_logger = get_logger()
_logger = logging.getLogger(__name__)


class Experiment(LegacyExperiment):
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/internal/api_clients/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import base64
import json
import logging
import os

from neptune.internal.utils.logger import get_logger
from neptune.legacy import envs
from neptune.legacy.api_exceptions import InvalidApiKey
from neptune.legacy.constants import (
Expand All @@ -27,7 +27,7 @@
)
from neptune.legacy.exceptions import NeptuneMissingApiTokenException

_logger = get_logger()
_logger = logging.getLogger(__name__)


class Credentials(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#

import json
import logging
import math
import os
import re
Expand Down Expand Up @@ -68,7 +69,6 @@
base64_encode,
)
from neptune.internal.utils import paths as alpha_path_utils
from neptune.internal.utils.logger import get_logger
from neptune.internal.utils.paths import parse_path
from neptune.legacy.api_exceptions import (
ExperimentNotFound,
Expand Down Expand Up @@ -112,7 +112,7 @@
)
from neptune.legacy.notebook import Notebook

_logger = get_logger()
_logger = logging.getLogger(__name__)

LegacyExperiment = namedtuple(
"LegacyExperiment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import os
import platform
import sys
Expand All @@ -30,7 +31,6 @@
update_session_proxies,
)
from neptune.internal.backends.hosted_client import NeptuneResponseAdapter
from neptune.internal.utils.logger import get_logger
from neptune.legacy.api_exceptions import (
ProjectNotFound,
WorkspaceNotFound,
Expand All @@ -48,7 +48,7 @@
from neptune.legacy.internal.api_clients.hosted_api_clients.utils import legacy_with_api_exceptions_handler
from neptune.legacy.projects import Project

_logger = get_logger()
_logger = logging.getLogger(__name__)


class HostedNeptuneBackendApiClient(HostedNeptuneMixin, BackendApiClient):
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_project(self, project_qualified_name):
response = self.backend_swagger_client.api.getProject(projectIdentifier=project_qualified_name).response()
warning = response.metadata.headers.get("X-Server-Warning")
if warning:
_logger.warning(click.style("{warning}{content}{end}".format(content=warning, **STYLES)))
click.echo("{warning}{content}{end}".format(content=warning, **STYLES))
project = response.result

return Project(
Expand Down Expand Up @@ -184,33 +184,33 @@ def _verify_version(self):
parsed_version = version.parse(self.client_lib_version)

if self._client_config.min_compatible_version and self._client_config.min_compatible_version > parsed_version:
styled_msg = click.style(
click.echo(
"ERROR: Minimal supported client version is {} (installed: {}). Please upgrade neptune-client".format(
self._client_config.min_compatible_version, self.client_lib_version
)
),
sys.stderr,
)
_logger.error(styled_msg)
raise UnsupportedClientVersion(
self.client_lib_version,
self._client_config.min_compatible_version,
self._client_config.max_compatible_version,
)
if self._client_config.max_compatible_version and self._client_config.max_compatible_version < parsed_version:
styled_msg = click.style(
click.echo(
"ERROR: Maximal supported client version is {} (installed: {}). Please downgrade neptune-client".format(
self._client_config.max_compatible_version, self.client_lib_version
)
),
sys.stderr,
)
_logger.error(styled_msg)
raise UnsupportedClientVersion(
self.client_lib_version,
self._client_config.min_compatible_version,
self._client_config.max_compatible_version,
)
if self._client_config.min_recommended_version and self._client_config.min_recommended_version > parsed_version:
styled_msg = click.style(
click.echo(
"WARNING: We recommend an upgrade to a new version of neptune-client - {} (installed - {}).".format(
self._client_config.min_recommended_version, self.client_lib_version
)
),
sys.stderr,
)
_logger.warning(styled_msg)
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import socket
import sys

import click
from bravado.client import SwaggerClient
from bravado_core.formatter import SwaggerFormat
from packaging import version
from six.moves import urllib

from neptune.internal.utils.logger import get_logger
from neptune.legacy.exceptions import (
CannotResolveHostname,
DeprecatedApiToken,
Expand All @@ -33,7 +34,7 @@
)
from neptune.legacy.internal.api_clients.hosted_api_clients.utils import legacy_with_api_exceptions_handler

_logger = get_logger()
_logger = logging.getLogger(__name__)

uuid_format = SwaggerFormat(
format="uuid",
Expand Down Expand Up @@ -74,10 +75,10 @@ def _create_client_config(self, api_token, backend_client):
min_compatible = getattr(config.pyLibVersions, "minCompatibleVersion", None)
max_compatible = getattr(config.pyLibVersions, "maxCompatibleVersion", None)
else:
styled_msg = click.style(
"ERROR: This client version is not supported by your Neptune instance. Please contant Neptune support."
click.echo(
"ERROR: This client version is not supported by your Neptune instance. Please contant Neptune support.",
sys.stderr,
)
_logger.error(styled_msg)
raise UnsupportedClientVersion(self.client_lib_version, None, "0.4.111")

multipart_upload_config_obj = getattr(config, "multiPartUpload", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#

import logging
import time

import requests
Expand All @@ -32,7 +33,6 @@
from urllib3.exceptions import NewConnectionError

from neptune.common.backends.utils import get_retry_from_headers_or_default
from neptune.internal.utils.logger import get_logger
from neptune.legacy.api_exceptions import (
ConnectionLost,
Forbidden,
Expand All @@ -41,7 +41,7 @@
Unauthorized,
)

_logger = get_logger()
_logger = logging.getLogger(__name__)


def legacy_with_api_exceptions_handler(func):
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/internal/api_clients/offline_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
from io import StringIO

from neptune.common.utils import NoopObject
from neptune.internal.utils.logger import get_logger
from neptune.legacy.backend import (
BackendApiClient,
LeaderboardApiClient,
)

_logger = get_logger()
_logger = logging.getLogger(__name__)


class OfflineBackendApiClient(BackendApiClient):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import threading
import time
from collections import namedtuple
Expand All @@ -24,7 +25,6 @@

from bravado.exception import HTTPUnprocessableEntity

from neptune.internal.utils.logger import get_logger
from neptune.legacy.exceptions import NeptuneException
from neptune.legacy.internal.channels.channels import (
ChannelIdWithValues,
Expand All @@ -34,7 +34,7 @@
)
from neptune.legacy.internal.threads.neptune_thread import NeptuneThread

_logger = get_logger()
_logger = logging.getLogger(__name__)


class ChannelsValuesSender(object):
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/internal/execution/execution_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import os
import sys
import time
Expand All @@ -26,7 +27,6 @@
is_ipython,
is_notebook,
)
from neptune.internal.utils.logger import get_logger
from neptune.legacy.internal.abort import (
CustomAbortImpl,
DefaultAbortImpl,
Expand All @@ -41,7 +41,7 @@
from neptune.legacy.internal.threads.hardware_metric_reporting_thread import HardwareMetricReportingThread
from neptune.legacy.internal.threads.ping_thread import PingThread

_logger = get_logger()
_logger = logging.getLogger(__name__)


class ExecutionContext(object):
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/internal/notebooks/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from neptune.internal.utils.logger import get_logger
import logging

_logger = get_logger()
_logger = logging.getLogger(__name__)


class MessageType(object):
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/internal/notebooks/notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import threading

from neptune.common.utils import is_ipython
from neptune.internal.utils.logger import get_logger
from neptune.legacy.internal.notebooks.comm import send_checkpoint_created

_logger = get_logger()
_logger = logging.getLogger(__name__)

_checkpoints_lock = threading.Lock()
_checkpoints = dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import time

from bravado.exception import HTTPError

from neptune.internal.utils.logger import get_logger
from neptune.legacy.exceptions import NeptuneException
from neptune.legacy.internal.threads.neptune_thread import NeptuneThread

_logger = get_logger()
_logger = logging.getLogger(__name__)


class HardwareMetricReportingThread(NeptuneThread):
Expand Down
5 changes: 3 additions & 2 deletions src/neptune/legacy/internal/threads/ping_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging

from bravado.exception import HTTPUnprocessableEntity

from neptune.internal.utils.logger import get_logger
from neptune.legacy.internal.threads.neptune_thread import NeptuneThread

_logger = get_logger()
_logger = logging.getLogger(__name__)


class PingThread(NeptuneThread):
Expand Down
4 changes: 2 additions & 2 deletions src/neptune/legacy/internal/utils/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
from functools import wraps
from http.client import (
NOT_FOUND,
Expand All @@ -21,14 +22,13 @@

from requests.exceptions import HTTPError

from neptune.internal.utils.logger import get_logger
from neptune.legacy.api_exceptions import (
ExperimentNotFound,
StorageLimitReached,
)
from neptune.legacy.exceptions import NeptuneException

_logger = get_logger()
_logger = logging.getLogger(__name__)


def extract_response_field(response, field_name):
Expand Down
Loading

0 comments on commit db2d036

Please sign in to comment.