JulianFrattini / cira

Python package for functions around the causality in requirements artifacts (CiRA) initiative.
http://www.cira.bth.se/
Apache License 2.0
10 stars 1 forks source link

Resolve requirements issue #5

Closed JulianFrattini closed 2 years ago

JulianFrattini commented 2 years ago

Installing the requirements as they are currently specified results in the following runtime error:


ValueError                                Traceback (most recent call last)
Input In [2], in <cell line: 4>()
      1 import os, dotenv
      2 dotenv.load_dotenv()
----> 4 from src.cira import CiRAConverter

File D:\gitlab_repos\CiRA\cira-main\src\cira.py:8, in <module>
      5 from src.classifiers.causalitydetection.causalclassifier import CausalClassifier
      7 # converters
----> 8 from src.converters.sentencetolabels.labeler import Labeler
      9 from src.converters.labelstograph.graphconverter import GraphConverter
     10 from src.converters.labelstograph.eventresolver import SimpleResolver

File D:\gitlab_repos\CiRA\cira-main\src\converters\sentencetolabels\labeler.py:1, in <module>
----> 1 from src.converters.sentencetolabels.model import MultiLabelRoBERTaCustomModel
      2 from transformers import RobertaTokenizerFast
      3 from transformers import BatchEncoding

File D:\gitlab_repos\CiRA\cira-main\src\converters\sentencetolabels\model.py:6, in <module>
      3 from transformers.modeling_outputs import TokenClassifierOutput
      4 from transformers import RobertaModel
----> 6 import pytorch_lightning as pl
      7 import torch
      8 import torch.nn as nn

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\pytorch_lightning\__init__.py:20, in <module>
     17 _PACKAGE_ROOT = os.path.dirname(__file__)
     18 _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)
---> 20 from pytorch_lightning import metrics  # noqa: E402
     21 from pytorch_lightning.callbacks import Callback  # noqa: E402
     22 from pytorch_lightning.core import LightningDataModule, LightningModule  # noqa: E402

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\pytorch_lightning\metrics\__init__.py:15, in <module>
      1 # Copyright The PyTorch Lightning team.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from pytorch_lightning.metrics.classification import (  # noqa: F401
     16     Accuracy,
     17     AUC,
     18     AUROC,
     19     AveragePrecision,
     20     ConfusionMatrix,
     21     F1,
     22     FBeta,
     23     HammingDistance,
     24     IoU,
     25     Precision,
     26     PrecisionRecallCurve,
     27     Recall,
     28     ROC,
     29     StatScores,
     30 )
     31 from pytorch_lightning.metrics.metric import Metric, MetricCollection  # noqa: F401
     32 from pytorch_lightning.metrics.regression import (  # noqa: F401
     33     ExplainedVariance,
     34     MeanAbsoluteError,
   (...)
     39     SSIM,
     40 )

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\pytorch_lightning\metrics\classification\__init__.py:14, in <module>
      1 # Copyright The PyTorch Lightning team.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 14 from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
     15 from pytorch_lightning.metrics.classification.auc import AUC  # noqa: F401
     16 from pytorch_lightning.metrics.classification.auroc import AUROC  # noqa: F401

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\pytorch_lightning\metrics\classification\accuracy.py:16, in <module>
      1 # Copyright The PyTorch Lightning team.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 from typing import Any, Callable, Optional
---> 16 from torchmetrics import Accuracy as _Accuracy
     18 from pytorch_lightning.metrics.utils import deprecated_metrics
     21 class Accuracy(_Accuracy):

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\__init__.py:14, in <module>
     11 _PACKAGE_ROOT = os.path.dirname(__file__)
     12 _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)
---> 14 from torchmetrics import functional  # noqa: E402
     15 from torchmetrics.aggregation import CatMetric, MaxMetric, MeanMetric, MinMetric, SumMetric  # noqa: E402
     16 from torchmetrics.audio import (  # noqa: E402
     17     PermutationInvariantTraining,
     18     ScaleInvariantSignalDistortionRatio,
   (...)
     21     SignalNoiseRatio,
     22 )

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\functional\__init__.py:14, in <module>
      1 # Copyright The PyTorch Lightning team.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 14 from torchmetrics.functional.audio.pit import permutation_invariant_training, pit_permutate
     15 from torchmetrics.functional.audio.sdr import scale_invariant_signal_distortion_ratio, signal_distortion_ratio
     16 from torchmetrics.functional.audio.snr import scale_invariant_signal_noise_ratio, signal_noise_ratio

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\functional\audio\__init__.py:14, in <module>
      1 # Copyright The PyTorch Lightning team.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 14 from torchmetrics.functional.audio.pit import permutation_invariant_training, pit_permutate  # noqa: F401
     15 from torchmetrics.functional.audio.sdr import (  # noqa: F401
     16     scale_invariant_signal_distortion_ratio,
     17     signal_distortion_ratio,
     18 )
     19 from torchmetrics.functional.audio.snr import scale_invariant_signal_noise_ratio, signal_noise_ratio  # noqa: F401

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\functional\audio\pit.py:21, in <module>
     18 import torch
     19 from torch import Tensor
---> 21 from torchmetrics.utilities.imports import _SCIPY_AVAILABLE
     23 # _ps_dict: cache of permutations
     24 # it's necessary to cache it, otherwise it will consume a large amount of time
     25 _ps_dict: dict = {}  # _ps_dict[str(spk_num)+str(device)] = permutations

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\utilities\__init__.py:1, in <module>
----> 1 from torchmetrics.utilities.checks import check_forward_full_state_property  # noqa: F401
      2 from torchmetrics.utilities.data import apply_to_collection  # noqa: F401
      3 from torchmetrics.utilities.distributed import class_reduce, reduce  # noqa: F401

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\utilities\checks.py:22, in <module>
     19 import torch
     20 from torch import Tensor
---> 22 from torchmetrics.utilities.data import select_topk, to_onehot
     23 from torchmetrics.utilities.enums import DataType
     26 def _check_for_empty_tensors(preds: Tensor, target: Tensor) -> bool:

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\utilities\data.py:19, in <module>
     16 import torch
     17 from torch import Tensor, tensor
---> 19 from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_1_6, _TORCH_GREATER_EQUAL_1_7, _TORCH_GREATER_EQUAL_1_8
     21 if _TORCH_GREATER_EQUAL_1_8:
     22     deterministic = torch.are_deterministic_algorithms_enabled

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\utilities\imports.py:119, in <module>
    117 _TORCHVISION_GREATER_EQUAL_0_8: Optional[bool] = _compare_version("torchvision", operator.ge, "0.8.0")
    118 _TQDM_AVAILABLE: bool = _package_available("tqdm")
--> 119 _TRANSFORMERS_AVAILABLE: bool = _package_available("transformers")
    120 _TRANSFORMERS_AUTO_AVAILABLE = _module_available("transformers.models.auto")
    121 _PESQ_AVAILABLE: bool = _package_available("pesq")

File D:\gitlab_repos\CiRA\cira-main\venv_python39\lib\site-packages\torchmetrics\utilities\imports.py:36, in _package_available(package_name)
     28 """Check if a package is available in your environment.
     29 
     30 >>> _package_available('os')
   (...)
     33 False
     34 """
     35 try:
---> 36     return find_spec(package_name) is not None
     37 except AttributeError:
     38     # Python 3.6
     39     return False

File ~\AppData\Local\Programs\Python\Python39\lib\importlib\util.py:114, in find_spec(name, package)
    112 else:
    113     if spec is None:
--> 114         raise ValueError('{}.__spec__ is None'.format(name))
    115     return spec

ValueError: transformers.__spec__ is None```
andreas-bauer commented 2 years ago

I also have problems with the requirements.txt. Some of the packages are too old so that they are not available for my M1 ARM architecture.

I was able to install the dependencies with the following version declaration:

numpy=1.23
pytest=7.1
python-dotenv=0.20
pytorch_lightning=1.7
tabulate=0.8
torch=1.12
transformers=4.6
JulianFrattini commented 2 years ago

Making the tool accessible requires reinvestigating its setup and virtualizing its execution. The following steps will be taken:

JulianFrattini commented 2 years ago

With the updated requirements and the new instructions included in the readme (e.g., requirement of Python 3.10 and the Rust compiler) I was able to run the system on another, fresh Windows machine.

andreas-bauer commented 2 years ago

The current requirements.txt works now for me. Tested on a Mac with M1 arm64 architecture.

JulianFrattini commented 2 years ago

@andreas-bauer fully containerized the development environment, hence all requirements issues are solved.