Exemplo n.º 1
0
    def test_lstm_symbols_provided(self) -> None:
        """Test obtaining symbols provided by a lib."""
        file_path = self._get_test_path("lstm_test.py")
        result = gather_symbols_provided(file_path)

        assert "version" in result
        assert "report" in result
        assert file_path in result["report"]
        assert set(result["report"][file_path]) == {
            "tests.data.lstm_test.RNN",
            "tests.data.lstm_test.X",
            "tests.data.lstm_test.Y",
            "tests.data.lstm_test.accuracy",
            "tests.data.lstm_test.batch_size",
            "tests.data.lstm_test.biases",
            "tests.data.lstm_test.correct_pred",
            "tests.data.lstm_test.display_step",
            "tests.data.lstm_test.init",
            "tests.data.lstm_test.learning_rate",
            "tests.data.lstm_test.logits",
            "tests.data.lstm_test.loss_op",
            "tests.data.lstm_test.mnist",
            "tests.data.lstm_test.num_classes",
            "tests.data.lstm_test.num_hidden",
            "tests.data.lstm_test.num_input",
            "tests.data.lstm_test.optimizer",
            "tests.data.lstm_test.prediction",
            "tests.data.lstm_test.timesteps",
            "tests.data.lstm_test.train_op",
            "tests.data.lstm_test.training_steps",
            "tests.data.lstm_test.weights",
        }
def main() -> None:
    """Obtain symbols provided by TensorFlow in various releases."""
    pypi = Source("https://pypi.org/simple")

    os.makedirs("data", exist_ok=True)

    for tensorflow_version in pypi.get_package_versions("tensorflow"):
        print(
            f"Obtaining info for TensorFlow in version {tensorflow_version!r}")
        artifacts = [
            a for a in pypi.get_package_artifacts("tensorflow",
                                                  tensorflow_version)
            if "manylinux" in a.artifact_name
        ]
        if len(artifacts) == 0:
            print(
                f"!!! no artifacts to download for TensorFlow in version {tensorflow_version}"
            )
            continue

        artifacts[0]._extract_py_module()
        symbols = gather_symbols_provided(artifacts[0].dir_name,
                                          ignore_errors=True)

        with open(f"data/tensorflow-{tensorflow_version}.json", "w") as f:
            json.dump(symbols, f, sort_keys=True, indent=2)
Exemplo n.º 3
0
def whatprovides(
    path: Optional[str] = None,
    ignore_errors: bool = False,
    include_private: bool = False,
) -> None:
    """Gather information about symbols provided by a module or a source file."""
    result = gather_symbols_provided(path,
                                     ignore_errors=ignore_errors,
                                     include_private=include_private)
    click.echo(json.dumps(result, indent=2, sort_keys=True))
Exemplo n.º 4
0
 def test_app9(self) -> None:
     file_path = self._get_test_path("app_9_test.py")
     result = gather_symbols_provided(file_path)
     assert "report" in result
     assert str(file_path) in result["report"]
     assert set(result["report"][str(file_path)]) == {
         "tests.data.app_9_test.A",
         "tests.data.app_9_test.B",
         "tests.data.app_9_test.GLOBAL_VAL",
         "tests.data.app_9_test.SomeClass",
         "tests.data.app_9_test.X",
         "tests.data.app_9_test.Y",
         "tests.data.app_9_test.async_signal_handler",
         "tests.data.app_9_test.b",
         "tests.data.app_9_test.signal_handler",
     }
Exemplo n.º 5
0
 def test_no_files(self) -> None:
     file_path = self._get_test_path("somenonexistingfileorfilepath")
     with pytest.raises(FileNotFoundError):
         gather_symbols_provided(file_path)
Exemplo n.º 6
0
 def test_empty(self) -> None:
     file_path = self._get_test_path("empty_test.py")
     result = gather_symbols_provided(file_path)
     assert "report" in result
     assert result["report"] == {file_path: []}
Exemplo n.º 7
0
 def test_version(self) -> None:
     file_path = self._get_test_path("empty_test.py")
     result = gather_symbols_provided(file_path)
     assert "version" in result
     assert result["version"] == invectio_version