Skip to content

Commit

Permalink
Change isort settings with localfolders and sections.
Browse files Browse the repository at this point in the history
Signed-off-by: Stanislav Beliaev <[email protected]>
  • Loading branch information
stasbel committed Jan 24, 2020
1 parent b371e31 commit 816f9c5
Show file tree
Hide file tree
Showing 54 changed files with 51 additions and 420 deletions.
4 changes: 2 additions & 2 deletions examples/applications/asr_service/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright (c) 2019 NVIDIA Corporation
import os

from app import routes # noqa
from flask import Flask
from ruamel.yaml import YAML

import nemo
import nemo.collections.asr as nemo_asr
from app import routes # noqa
from flask import Flask

app = Flask(__name__)
# make sure WORK_DIR exists before calling your service
Expand Down
5 changes: 3 additions & 2 deletions examples/applications/asr_service/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import os
import time

import nemo
import nemo.collections.asr as nemo_asr
from app import (
ENABLE_NGRAM,
MODEL_YAML,
Expand All @@ -19,6 +17,9 @@
from flask import request
from werkzeug.utils import secure_filename

import nemo
import nemo.collections.asr as nemo_asr

try:
from app import beam_search_with_lm
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion examples/nlp/bert_pretraining.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
import os

import torch
from pytorch_transformers import BertConfig

import nemo
import nemo.collections.nlp as nemo_nlp
from nemo.collections.nlp.data.datasets.utils import BERTPretrainingDataDesc
from nemo.collections.nlp.transformer.utils import gelu
from nemo.collections.nlp.utils.callbacks.bert_pretraining import eval_epochs_done_callback, eval_iter_callback
from nemo.utils.lr_policies import get_lr_policy
from pytorch_transformers import BertConfig

parser = argparse.ArgumentParser(description='BERT pretraining')
parser.add_argument("--local_rank", default=None, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/tts/tts_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import numpy as np
from ruamel.yaml import YAML
from scipy.io.wavfile import write
from tacotron2 import create_NMs

import nemo
import nemo.collections.asr as nemo_asr
import nemo.collections.tts as nemo_tts
from tacotron2 import create_NMs


def parse_args():
Expand Down
3 changes: 1 addition & 2 deletions nemo/backends/pytorch/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import torch.optim as optim

import nemo
from nemo.backends.pytorch.nm import TrainableNM

from ...core import DeploymentFormat, DeviceType, NeuralModule, NmTensor
from ...core.callbacks import ActionCallback, EvaluatorCallback, SimpleLossLoggerCallback
from ...core.neural_factory import Actions, ModelMode, Optimization
Expand All @@ -23,6 +21,7 @@
from .module_wrapper import TrainableNeuralModuleWrapper
from .nm import DataLayerNM
from .optimizers import AdamW, Novograd, master_params
from nemo.backends.pytorch.nm import TrainableNM

# these imports will happen on as-needed basis
amp = None
Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/asr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =============================================================================
from nemo.core import Backend

from .audio_preprocessing import *
from .beam_search_decoder import BeamSearchDecoderWithLM
from .data_layer import AudioToTextDataLayer, KaldiFeatureDataLayer, TranscriptDataLayer
from .greedy_ctc_decoder import GreedyCTCDecoder
from .jasper import JasperDecoderForCTC, JasperEncoder
from .las.misc import JasperRNNConnector
from .losses import CTCLossNM
from nemo.core import Backend

__all__ = [
'Backend',
Expand Down
5 changes: 2 additions & 3 deletions nemo/collections/asr/audio_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@

import torch

from .parts.features import FilterbankFeatures
from .parts.spectr_augment import SpecAugment, SpecCutout
from nemo.backends.pytorch import NonTrainableNM
from nemo.core import Optimization
from nemo.core.neural_types import *

from .parts.features import FilterbankFeatures
from .parts.spectr_augment import SpecAugment, SpecCutout

try:
import torchaudio

Expand Down
5 changes: 2 additions & 3 deletions nemo/collections/asr/data_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import torch

import nemo
from .parts.dataset import AudioDataset, KaldiFeatureDataset, TranscriptDataset, seq_collate_fn
from .parts.features import WaveformFeaturizer
from nemo.backends.pytorch import DataLayerNM
from nemo.core import DeviceType
from nemo.core.neural_types import *
from nemo.utils.misc import pad_to

from .parts.dataset import AudioDataset, KaldiFeatureDataset, TranscriptDataset, seq_collate_fn
from .parts.features import WaveformFeaturizer

__all__ = [
'AudioToTextDataLayer',
'KaldiFeatureDataLayer',
Expand Down
1 change: 0 additions & 1 deletion nemo/collections/asr/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import torch

import nemo

from .metrics import word_error_rate


Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/asr/jasper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import torch.nn as nn
import torch.nn.functional as F

from .parts.jasper import JasperBlock, init_weights, jasper_activations
from nemo.backends.pytorch.nm import TrainableNM
from nemo.core.neural_types import (
AxisType,
Expand All @@ -17,8 +18,6 @@
TimeTag,
)

from .parts.jasper import JasperBlock, init_weights, jasper_activations


class JasperEncoder(TrainableNM):
"""
Expand Down
1 change: 0 additions & 1 deletion nemo/collections/asr/parts/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from torch_stft import STFT

import nemo

from .perturb import AudioAugmentor
from .segment import AudioSegment

Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/asr/parts/perturb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import librosa
from scipy import signal

from nemo.collections.asr.parts import collections, parsers

from .segment import AudioSegment
from nemo.collections.asr.parts import collections, parsers


class Perturbation(object):
Expand Down
1 change: 0 additions & 1 deletion nemo/collections/nlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# =============================================================================

import nemo

from .data import *
from .huggingface import *
from .modules import *
Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/nlp/data/data_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
from torch.utils import data as pt_data

import nemo
from .datasets import *
from nemo.backends.pytorch.nm import DataLayerNM
from nemo.core.neural_types import *

from .datasets import *


class TextDataLayer(DataLayerNM):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from torch.utils.data import Dataset

import nemo

from . import utils


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from torch.utils.data import Dataset

import nemo

from . import utils


Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/nlp/data/datasets/squad.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from tqdm import tqdm

import nemo
from nemo.collections.nlp.utils.nlp_utils import _is_whitespace

from ...utils.metrics.squad_metrics import (
_compute_softmax,
_get_best_indexes,
Expand All @@ -42,6 +40,7 @@
normalize_answer,
)
from .utils import DataProcessor
from nemo.collections.nlp.utils.nlp_utils import _is_whitespace


"""
Expand Down
1 change: 0 additions & 1 deletion nemo/collections/nlp/data/datasets/token_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from torch.utils.data import Dataset

import nemo

from . import utils


Expand Down
1 change: 0 additions & 1 deletion nemo/collections/nlp/data/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from tqdm import tqdm

import nemo

from ...utils.nlp_utils import get_vocab, label2idx, write_vocab, write_vocab_in_order

DATABASE_EXISTS_TMP = '{} dataset has already been processed and stored at {}'
Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/nlp/modules/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

import torch.nn as nn

from ..transformer.utils import transformer_weights_init
from nemo.backends.pytorch.common import MultiLayerPerceptron
from nemo.backends.pytorch.nm import LossNM, TrainableNM
from nemo.collections.nlp.transformer.utils import gelu
from nemo.core.neural_types import *

from ..transformer.utils import transformer_weights_init

ACT2FN = {"gelu": gelu, "relu": nn.functional.relu}


Expand Down
5 changes: 2 additions & 3 deletions nemo/collections/nlp/modules/losses.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import torch
from torch import nn

from nemo.backends.pytorch.nm import LossNM
from nemo.core.neural_types import *

from ..utils.nlp_utils import mask_padded_tokens
from .pytorch_utils import SmoothedCrossEntropyLoss
from nemo.backends.pytorch.nm import LossNM
from nemo.core.neural_types import *

__all__ = [
'JointIntentSlotLoss',
Expand Down
5 changes: 2 additions & 3 deletions nemo/collections/nlp/modules/transformer_nm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

import math

from nemo.backends.pytorch.nm import LossNM, TrainableNM
from nemo.core.neural_types import *

from ..transformer import (
BeamSearchSequenceGenerator,
GreedySequenceGenerator,
Expand All @@ -22,6 +19,8 @@
TransformerEncoder,
)
from ..transformer.utils import transformer_weights_init
from nemo.backends.pytorch.nm import LossNM, TrainableNM
from nemo.core.neural_types import *


class TransformerEncoderNM(TrainableNM):
Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/nlp/utils/callbacks/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

import numpy as np

from nemo.collections.asr.metrics import word_error_rate

from ..metrics.sacrebleu import corpus_bleu
from nemo.collections.asr.metrics import word_error_rate

GLOBAL_KEYS = ["eval_loss", "ref", "sys", "sent_ids", "nonpad_tokens"]

Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/nlp/utils/metrics/sacrebleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
from itertools import zip_longest
from typing import Iterable, List, Tuple, Union

from nemo import logging

from .fairseq_tokenizer import tokenize_en
from nemo import logging

VERSION = '1.3.5'

Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/simple_gan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =============================================================================
from nemo.core import Backend

from .gan import *
from nemo.core import Backend

backend = Backend.PyTorch
3 changes: 1 addition & 2 deletions nemo/collections/tts/data_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import torch

import nemo
from .parts.datasets import AudioOnlyDataset
from nemo.backends.pytorch.nm import DataLayerNM
from nemo.core import DeviceType
from nemo.core.neural_types import *

from .parts.datasets import AudioOnlyDataset


class AudioDataLayer(DataLayerNM):
"""
Expand Down
5 changes: 2 additions & 3 deletions nemo/collections/tts/tacotron2_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from torch import nn
from torch.nn.functional import pad

from nemo.backends.pytorch.nm import LossNM, NonTrainableNM, TrainableNM
from nemo.core.neural_types import *

from .parts.layers import get_mask_from_lengths
from .parts.tacotron2 import Decoder, Encoder, Postnet
from nemo.backends.pytorch.nm import LossNM, NonTrainableNM, TrainableNM
from nemo.core.neural_types import *

__all__ = [
"MakeGate",
Expand Down
3 changes: 1 addition & 2 deletions nemo/collections/tts/waveglow_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import numpy as np
import torch

from .parts.waveglow import WaveGlow
from nemo.backends.pytorch.nm import LossNM, TrainableNM
from nemo.core.neural_types import *

from .parts.waveglow import WaveGlow

__all__ = ["WaveGlowNM", "WaveGlowInferNM", "WaveGlowLoss"]


Expand Down
1 change: 0 additions & 1 deletion nemo/core/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from collections import namedtuple

import nemo

from ..utils import get_checkpoint_from_dir


Expand Down
1 change: 0 additions & 1 deletion nemo/core/neural_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import numpy as np

import nemo

from ..utils import ExpManager
from .callbacks import ActionCallback, EvaluatorCallback
from .neural_types import *
Expand Down
5 changes: 2 additions & 3 deletions nemo/core/neural_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from inspect import getargvalues, stack
from typing import Dict, List, Optional, Set, Tuple

from nemo.core import NeuralModuleFactory
from nemo.utils.decorators.deprecated import deprecated

from .neural_factory import DeviceType, Optimization
from .neural_types import (
CanNotInferResultNeuralType,
Expand All @@ -23,6 +20,8 @@
NeuralTypeComparisonResult,
NmTensor,
)
from nemo.core import NeuralModuleFactory
from nemo.utils.decorators.deprecated import deprecated


class WeightShareTransform(Enum):
Expand Down
Loading

0 comments on commit 816f9c5

Please sign in to comment.