Commit 9d2efe72 authored by mova's avatar mova
Browse files

move from local imports to global ones: `from ...config import conf` -> `from...

move from local imports to global ones: `from ...config import conf` -> `from fgsim.config import conf`
parent 0094b7e7
"""Main module."""
import importlib
import os
import sys
import comet_ml
......@@ -8,6 +9,9 @@ from omegaconf import OmegaConf
from .utils.logger import logger
# Add the project to the path, -> `import fgsim.x`
sys.path.append(os.path.dirname(os.path.realpath(".")))
def main():
# always reload the local modules
......
import torch
from ..config import conf
from fgsim.config import conf
def split_layer_subgraphs(batch):
......
......@@ -2,7 +2,7 @@ import numpy as np
import torch
from torch_geometric.data import Data
from ..config import conf
from fgsim.config import conf
def arrpos(ilayer, irow, icolumn, shape):
......
import torch
from torch_geometric.data import Data
from ..config import conf
from ..geo.graph import grid_to_graph
from fgsim.config import conf
from fgsim.geo.graph import grid_to_graph
def transform(data_dict) -> Data:
......
......@@ -8,9 +8,10 @@ import numpy as np
import torch_geometric
from torch.multiprocessing import Queue
from ..config import conf
from ..geo.batch_stack import split_layer_subgraphs
from ..geo.transform import transform
from fgsim.config import conf
from fgsim.geo.batch_stack import split_layer_subgraphs
from fgsim.geo.transform import transform
from . import qf
......
......@@ -8,7 +8,8 @@ import numpy as np
import torch
from torch.multiprocessing import Queue
from ..config import conf
from fgsim.config import conf
from . import qf
......
......@@ -2,8 +2,9 @@ from multiprocessing.queues import Empty, Full
import torch_geometric
from ...utils.batch_utils import clone_batch
from ...utils.logger import logger
from fgsim.utils.batch_utils import clone_batch
from fgsim.utils.logger import logger
from .terminate_queue import TerminateQueue
......
from collections.abc import Iterable
from multiprocessing.queues import Empty
from ...utils.logger import logger
from fgsim.utils.logger import logger
from .step_base import StepBase
from .terminate_queue import TerminateQueue
......
......@@ -3,8 +3,9 @@ from multiprocessing.queues import Empty
from torch import multiprocessing as mp
from ...utils.count_iterations import CountIterations
from ...utils.logger import logger
from fgsim.utils.count_iterations import CountIterations
from fgsim.utils.logger import logger
from .step_base import StepBase
from .terminate_queue import TerminateQueue
......
......@@ -2,7 +2,8 @@ from multiprocessing.queues import Empty
from torch import multiprocessing as mp
from ...utils.logger import logger
from fgsim.utils.logger import logger
from .step_base import StepBase
from .terminate_queue import TerminateQueue
......
......@@ -6,8 +6,9 @@ from multiprocessing.queues import Queue as queues_class
from prettytable import PrettyTable
from torch import multiprocessing as mp
from ...config import conf
from ...utils.logger import logger
from fgsim.config import conf
from fgsim.utils.logger import logger
from .in_out import InputStep, OutputStep
from .step_base import StepBase
......
......@@ -6,8 +6,8 @@ import torch
import torch_geometric
from torch import multiprocessing as mp
from ...utils.batch_utils import batch_to_numpy_dict, clone_batch
from ...utils.logger import logger
from fgsim.utils.batch_utils import batch_to_numpy_dict, clone_batch
from fgsim.utils.logger import logger
class StepBase:
......
......@@ -12,13 +12,14 @@ import numpy as np
import torch
import yaml
from ..config import conf
from ..utils.logger import logger
from fgsim.config import conf
from fgsim.utils.logger import logger
from . import qf
# Import the specified processing sequence
process_seq = importlib.import_module(
f"..io.{conf.loader.name}", "fgsim.models"
f"fgsim.io.{conf.loader.name}", "fgsim.models"
).process_seq
......
from omegaconf import OmegaConf
from ..config import conf
from ..utils.logger import logger
from fgsim.config import conf
from fgsim.utils.logger import logger
from .train_state import TrainState
......
......@@ -4,14 +4,14 @@ import os
import torch
from omegaconf import OmegaConf
from ..config import conf, device
from ..utils.check_for_nans import contains_nans
from ..utils.count_parameters import count_parameters
from ..utils.logger import logger
from fgsim.config import conf, device
from fgsim.utils.check_for_nans import contains_nans
from fgsim.utils.count_parameters import count_parameters
from fgsim.utils.logger import logger
# Import the specified model
ModelClass = importlib.import_module(
f"..models.{conf.model.name}", "fgsim.models"
f"fgsim.models.{conf.model.name}", "fgsim.models"
).ModelClass
......
......@@ -3,11 +3,12 @@ import pandas as pd
import torch
from tqdm import tqdm
from ..config import conf, device
from ..io.queued_dataset import QueuedDataLoader
from ..monitor import setup_experiment, setup_writer
from ..utils.batch_utils import move_batch_to_device
from ..utils.logger import logger
from fgsim.config import conf, device
from fgsim.io.queued_dataset import QueuedDataLoader
from fgsim.monitor import setup_experiment, setup_writer
from fgsim.utils.batch_utils import move_batch_to_device
from fgsim.utils.logger import logger
from .holder import model_holder
from .train_state import TrainState
......
......@@ -2,10 +2,11 @@ import torch
from omegaconf import OmegaConf
from torch.profiler import ProfilerActivity, profile
from ..config import conf, device
from ..io.queued_dataset import QueuedDataLoader
from ..monitor import setup_writer
from ..utils.logger import logger
from fgsim.config import conf, device
from fgsim.io.queued_dataset import QueuedDataLoader
from fgsim.monitor import setup_writer
from fgsim.utils.logger import logger
from .holder import model_holder
......
......@@ -5,8 +5,9 @@ import omegaconf
from comet_ml.experiment import BaseExperiment
from torch.utils.tensorboard import SummaryWriter
from ..config import conf
from ..io.queued_dataset import QueuedDataLoader
from fgsim.config import conf
from fgsim.io.queued_dataset import QueuedDataLoader
from .holder import ModelHolder
......
......@@ -5,11 +5,12 @@ import torch_geometric
from omegaconf import OmegaConf
from tqdm import tqdm
from ..config import conf, device
from ..io.queued_dataset import QueuedDataLoader
from ..monitor import setup_experiment, setup_writer
from ..utils.batch_utils import move_batch_to_device
from ..utils.logger import logger
from fgsim.config import conf, device
from fgsim.io.queued_dataset import QueuedDataLoader
from fgsim.monitor import setup_experiment, setup_writer
from fgsim.utils.batch_utils import move_batch_to_device
from fgsim.utils.logger import logger
from .early_stopping import early_stopping
from .holder import model_holder
from .train_state import TrainState
......
......@@ -3,10 +3,11 @@ from copy import deepcopy
import torch
from tqdm import tqdm
from ..config import conf, device
from ..utils.batch_utils import move_batch_to_device
from ..utils.check_for_nans import check_chain_for_nans
from ..utils.logger import logger
from fgsim.config import conf, device
from fgsim.utils.batch_utils import move_batch_to_device
from fgsim.utils.check_for_nans import check_chain_for_nans
from fgsim.utils.logger import logger
from .train_state import TrainState
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment