text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""Run doctest on all markdown files in the docs/ folder."""
import sys
import warnings
import pytest
pytest.importorskip("rdflib")
pytest.importorskip("yaml")
pytest.importorskip("pint")
pytest.importorskip("pyld")
@pytest.mark.skipif(sys.version_info < (3, 9), reason="pint needs Python 3.9")
def test_markdown_do... | EMMC-ASBL/tripper | tests/test_markdown_doctest.py | .py | 9df59656d22288ff | 7.09 | 14 |
"""Test namespaces."""
# pylint: disable=invalid-name,duplicate-code,import-outside-toplevel
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from pathlib import Path
from typing import Callable
def test_namespaces() -> None:
"""Test namespaces."""
pytest.importorskip("rdflib")
... | EMMC-ASBL/tripper | tests/test_namespace.py | .py | 5af0e944115cf5e4 | 7.09 | 14 |
"""Test session."""
def test_session():
"""Test session."""
import pytest
pytest.importorskip("yaml")
from paths import indir
from tripper import Literal, Session
session = Session(config=indir / "session.yaml")
ts = session.get_triplestore("RdflibTest")
EX = ts.bind("ex", "http://... | EMMC-ASBL/tripper | tests/test_session.py | .py | b5a12e25c8c47e89 | 8.09 | 14 |
"""Test using SPARQL via Tripper."""
# pylint: disable=invalid-name,import-outside-toplevel
import pytest
# if True:
def test_sparql_select():
"""Test SPARQL SELECT query."""
pytest.importorskip("rdflib")
from tripper import Triplestore
# Load pre-inferred EMMO
ts = Triplestore("rdflib", base_i... | EMMC-ASBL/tripper | tests/test_sparql.py | .py | 6220761b7165c53a | 7.09 | 14 |
"""Test triplestore.
If backend is given, only that backend will be tested. Otherwise all
installed backends are tested one by one.
"""
# pylint: disable=duplicate-code,comparison-with-callable,invalid-name
# pylint: disable=import-outside-toplevel
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
... | EMMC-ASBL/tripper | tests/test_triplestore.py | .py | 907ddd82d33a57a3 | 7.09 | 14 |
"""Test utils"""
# pylint: disable=invalid-name,too-few-public-methods,import-outside-toplevel
import pytest
def test_AttrDict():
"""Test AttrDict."""
from tripper.utils import AttrDict
d = AttrDict(a=1, b=2)
assert d.a == 1
assert repr(d) == """AttrDict({
'a': 1,
'b': 2,
})"""
assert r... | EMMC-ASBL/tripper | tests/test_utils.py | .py | e256dcaf2efe84ef | 7.09 | 14 |
"""Test the tripper.units module."""
import sys
import pytest
pytest.importorskip("pint")
pytest.importorskip("rdflib")
def test_get_unit_triplestore():
"""Test get_unit_triplestore()."""
from tripper import EMMO, units
ts = units.units.get_unit_triplestore()
assert ts.has(EMMO.Atom)
def test_ba... | EMMC-ASBL/tripper | tests/units/test_units.py | .py | ea8c31a002d1b615 | 8.09 | 14 |
"""Implementation of triplestore backends"""
from importlib import import_module
# A dict mapping backend names to a list of dependencies
backend_dependencies = {
"rdflib": ["rdflib"],
"ontopy": ["EMMOntoPy"],
}
def get_backends(only_available=False):
"""Returns a list with the name of backends.
If... | EMMC-ASBL/tripper | tripper/backends/__init__.py | .py | 1cfd4110f995acdc | 7.59 | 14 |
"""Backend for DLite collections."""
# pylint: disable=protected-access,invalid-name
from typing import TYPE_CHECKING
from tripper.literal import Literal
from tripper.utils import parse_object
if TYPE_CHECKING: # pragma: no cover
from collections.abc import Sequence
from typing import Generator, List, Optio... | EMMC-ASBL/tripper | tripper/backends/collection.py | .py | ad20ed4ed1504a2f | 7.59 | 14 |
"""Backend for EMMOntoPy.
For developers: The usage of `s`, `p`, and `o` represent the different parts of
an RDF Triple: subject, predicate, and object.
"""
# pylint: disable=protected-access
import os
import tempfile
from typing import TYPE_CHECKING
from tripper.literal import Literal
try:
from ontopy.ontology... | EMMC-ASBL/tripper | tripper/backends/ontopy.py | .py | 294b1f8593012bc1 | 7.59 | 14 |
"""Backend for RDFLib.
For developers: The usage of `s`, `p`, and `o` represent the different parts of
an RDF Triple: subject, predicate, and object.
There is a issue with rdflib raising an `urllib.error.HTTPError`
exception if you don't have write permissions to the cache directory.
See [Known issues](https://emmc-a... | EMMC-ASBL/tripper | tripper/backends/rdflib.py | .py | dbba3cefb0e5d393 | 7.59 | 14 |
"""Backend for SPARQLWrapper"""
import re
from typing import TYPE_CHECKING
from rdflib import Graph
from tripper import Literal
from tripper.backends.rdflib import _convert_triples_to_tripper
from tripper.errors import TripperError
from tripper.utils import check_service_availability
try:
from SPARQLWrapper imp... | EMMC-ASBL/tripper | tripper/backends/sparqlwrapper.py | .py | aeb89a08c1fdb79e | 7.59 | 14 |
# pylint: disable=line-too-long
"""Tripper module for converting between RDF and other repetations.
Example use:
```python
>>> from tripper import DCTERMS, Literal, Triplestore
>>> from tripper.convert import load_container, save_container
>>> ts = Triplestore("rdflib")
>>> dataset = {"a": 1, "b": 2}
>>> save_contai... | EMMC-ASBL/tripper | tripper/convert/convert.py | .py | 8d988b789d76561c | 7.59 | 14 |
# pylint: disable=redefined-builtin,invalid-name
"""A module for providing access to data based on data documentation
from the datasets module.
High-level functions for accessing and storing actual data:
- `load()`: Load documented dataset from its source.
- `save()`: Save documented dataset to a data resource.
... | EMMC-ASBL/tripper | tripper/datadoc/dataaccess.py | .py | d95d9d73ffa9eee3 | 7.59 | 14 |
"""
Module for Catalog base class
"""
import logging
from abc import ABC
from pathlib import Path
from typing import Type
import astropy.table
from mirar.catalog.base.errors import CatalogCacheError
from mirar.data import Image
from mirar.data.utils import get_image_center_wcs_coords
from mirar.paths import BASE_NAM... | winter-telescope/mirar | mirar/catalog/base/base_catalog.py | .py | bbeb6913b0c9d1c4 | 7.54 | 11 |
"""
Module for obtaining a Gaia/2Mass catalog
"""
import logging
from abc import ABC
from typing import Optional
import astropy.table
import astropy.units as u
import numpy as np
from astropy.coordinates import SkyCoord
from mirar.catalog.base.base_catalog import BaseCatalog
from mirar.utils.ldac_tools import get_ta... | winter-telescope/mirar | mirar/catalog/base/base_gaia.py | .py | 463f763426b7530e | 7.54 | 11 |
"""
Module for Catalog base class
"""
from pathlib import Path
import astropy.table
from mirar.catalog.base.base_catalog import BaseCatalog
from mirar.utils.ldac_tools import get_table_from_ldac
class CatalogFromFile(BaseCatalog):
"""
Local catalog from file
"""
abbreviation = "local"
def __i... | winter-telescope/mirar | mirar/catalog/base/catalog_from_file.py | .py | bc8d3e696ecda277 | 7.54 | 11 |
"""
Module containing the base Kowalski catalog object
"""
import logging
import os
from abc import ABC
from typing import Optional
from penquins import Kowalski
from mirar.catalog.base.base_xmatch_catalog import BaseXMatchCatalog
from mirar.errors import ProcessorError
logger = logging.getLogger(__name__)
class ... | winter-telescope/mirar | mirar/catalog/kowalski/base_kowalski_catalog.py | .py | a58c2fce24d0510d | 7.54 | 11 |
"""
Module for querying Gaia using Kowalski
"""
from mirar.catalog.kowalski.base_kowalski_catalog import BaseKowalskiXMatch
class Gaia(BaseKowalskiXMatch):
"""
Gaia Kowalski catalog
"""
catalog_name = "Gaia_EDR3"
abbreviation = "gaia"
projection = {
"_id": 1,
"ra": 1,
... | winter-telescope/mirar | mirar/catalog/kowalski/gaia.py | .py | cb2832cd575989c4 | 7.54 | 11 |
"""
Module for querying PS1 using Kowalski
"""
from mirar.catalog.kowalski.base_kowalski_catalog import BaseKowalskiXMatch
class PS1(BaseKowalskiXMatch):
"""
PS1 Kowalski catalog
"""
catalog_name = "PS1_DR1"
abbreviation = "ps"
projection = {
"_id": 1,
"raMean": 1,
"d... | winter-telescope/mirar | mirar/catalog/kowalski/ps1.py | .py | b9d2a1dcbe04db1d | 7.54 | 11 |
"""
Module for querying 2MASS using Kowalski
"""
from mirar.catalog.base.base_gaia import offsets_2mass
from mirar.catalog.kowalski.base_kowalski_catalog import BaseKowalskiXMatch
class TMASS(BaseKowalskiXMatch):
"""
2MASS Kowalski catalog
"""
catalog_name = "2MASS_PSC"
abbreviation = "tm"
p... | winter-telescope/mirar | mirar/catalog/kowalski/tmass.py | .py | c04b7cf5fe8c56de | 7.54 | 11 |
"""
Composite catalog for Gaia 2Mass
"""
import logging
from typing import Type
from mirar.catalog.base.base_catalog import BaseCatalog, BaseMultiBackendCatalog
from mirar.catalog.tap.gaia2mass import Gaia, Gaia2MassARI, Gaia2MassTAP, gaia_ari
from mirar.catalog.vizier.gaia2mass import Gaia2MassVizier
logger = loggi... | winter-telescope/mirar | mirar/catalog/multibackend/gaia2mass.py | .py | ecda1e6eb6ae64a9 | 7.54 | 11 |
"""
Module for obtaining a Gaia/2Mass catalog
"""
import logging
import astropy.table
from astroquery.gaia import Gaia
from astroquery.utils.tap.core import TapPlus
from mirar.catalog.base.base_catalog import DEFAULT_SNR_THRESHOLD
from mirar.catalog.base.base_gaia import BaseGaia2Mass
logger = logging.getLogger(__n... | winter-telescope/mirar | mirar/catalog/tap/gaia2mass.py | .py | 2f7a6455a835e5d3 | 7.54 | 11 |
"""
Module containing base class for a Vizier catalog
"""
import logging
import time
from abc import ABC
import astropy.table
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table
from astroquery.vizier import Vizier
from requests.exceptions import ChunkedEncodingError
fr... | winter-telescope/mirar | mirar/catalog/vizier/base_vizier_catalog.py | .py | d2e58065ce4aff3e | 7.54 | 11 |
"""
Module for querying Gaia catalog
"""
import logging
import astropy.table
from mirar.catalog.vizier.base_vizier_catalog import VizierCatalog
logger = logging.getLogger(__name__)
# Disable astroquery warnings
logging.getLogger("astroquery").setLevel(logging.WARNING)
class GaiaVizier(VizierCatalog):
"""
... | winter-telescope/mirar | mirar/catalog/vizier/gaia.py | .py | 5e5249d6fd9eab78 | 7.54 | 11 |
"""
Module for querying Gaia catalog
"""
import logging
import astropy.table
from astropy.table import join
from mirar.catalog.base.base_gaia import BaseGaia2Mass
from mirar.catalog.vizier.base_vizier_catalog import VizierCatalog
logger = logging.getLogger(__name__)
# Disable astroquery warnings
logging.getLogger(... | winter-telescope/mirar | mirar/catalog/vizier/gaia2mass.py | .py | 4d6ca4069998e4a6 | 7.54 | 11 |
"""
Module for querying PS1 catalog
"""
import logging
import astropy.table
import numpy as np
from astropy.table import Table, join
from mirar.catalog.vizier.base_vizier_catalog import VizierCatalog
from mirar.errors import ProcessorError
logger = logging.getLogger(__name__)
class NotInPS1Error(ProcessorError):
... | winter-telescope/mirar | mirar/catalog/vizier/ps1.py | .py | 053ca0b98cca2c52 | 7.54 | 11 |
"""
Module containing SDSS Vizier catalog
"""
import logging
from pathlib import Path
import numpy as np
import requests
from pydl.pydlutils import mangle
from mirar.catalog.vizier.base_vizier_catalog import VizierCatalog
from mirar.errors import ProcessorError
from mirar.paths import base_output_dir
logger = loggi... | winter-telescope/mirar | mirar/catalog/vizier/sdss.py | .py | ef5052e6abb33589 | 7.54 | 11 |
"""
Module containing Skymapper Vizier catalog
"""
import logging
from mirar.catalog.vizier.base_vizier_catalog import VizierCatalog
from mirar.errors import ProcessorError
logger = logging.getLogger(__name__)
class NotInSkymapperError(ProcessorError):
"""Error for source not in Skymapper"""
def in_skymapper... | winter-telescope/mirar | mirar/catalog/vizier/skymapper.py | .py | a84a739227588ab2 | 7.54 | 11 |
"""
This contains the base data classes for the :module:`wintedrp.processors`.
The smallest unit is a :class:`~mirar.data.base_data.DataBlock` object,
corresponding to a single image.
These :class:`~mirar.data.base_data.DataBlock` objects are grouped into
:class:`~mirar.data.base_data.DataBatch` objects.
Each :class:`... | winter-telescope/mirar | mirar/data/base_data.py | .py | ed296744f35024df | 7.54 | 11 |
"""
Central module for handling the cache, currently used only for storing image data.
"""
import logging
import os
from pathlib import Path
import numpy as np
logger = logging.getLogger(__name__)
USE_CACHE: bool = os.getenv("USE_MIRAR_CACHE", "true") in ["true", "True", True, 1, "1"]
if not USE_CACHE:
if os.g... | winter-telescope/mirar | mirar/data/cache.py | .py | b06e489abbe636ab | 7.54 | 11 |
"""
Module to specify the input data classes for
:class:`mirar.processors.base_processor.ImageHandler`
The basic idea of the code is to pass
:class:`~mirar.data.base_data.DataBlock` objects
through a series of :class:`~wintedrp.processors.BaseProcessor` objects.
Since a given image can easily be ~10-100Mb, and there m... | winter-telescope/mirar | mirar/data/image_data.py | .py | 3033661b3f3e06d9 | 7.54 | 11 |
"""
Module for encoding/decoding numpy 2D images to gziped fits files
"""
import gzip
import io
import numpy as np
from astropy.io import fits
def decode_img(compressed_bytes: bytes) -> np.ndarray:
"""
Function to parse a cutout (gziped fits file) into a numpy array
:param compressed_bytes: Gziped fits... | winter-telescope/mirar | mirar/data/utils/compress.py | .py | 73b955eac37b319c | 7.54 | 11 |
"""
Functions to get image coordinates from WCS
"""
import logging
from pathlib import Path
import numpy as np
from astropy import units as u
from astropy.io import fits
from astropy.units import Quantity
from astropy.wcs import WCS
from mirar.data import Image
logger = logging.getLogger(__name__)
def get_corners... | winter-telescope/mirar | mirar/data/utils/coords.py | .py | 6435f224fa7b9bdb | 7.54 | 11 |
"""
Module to define PSQL database tables using sqlalchemy
"""
import logging
from datetime import date
from typing import Any, ClassVar, Type
import pandas as pd
from psycopg import errors
from pydantic import (
BaseModel,
ConfigDict,
Field,
FieldValidationInfo,
field_validator,
model_validat... | winter-telescope/mirar | mirar/database/base_model.py | .py | 3548140d921bbce6 | 7.54 | 11 |
"""
Module to define PSQL database tables using sqlalchemy
"""
import logging
from sqlalchemy import inspect
logger = logging.getLogger(__name__)
class BaseTable:
"""
Parent class for database tables. Tables should inherit from this
and DeclarativeBase.
"""
@property
def __tablename__(self... | winter-telescope/mirar | mirar/database/base_table.py | .py | d1df929f0771d8e7 | 7.54 | 11 |
"""
Module for DBQueryConstraints to carefully specify postgres query constraints
"""
import numpy as np
POSTGRES_ACCEPTED_COMPARISONS = ["=", "<", ">", "<=", ">=", "between", "<>", "!="]
class DBQueryConstraints:
"""
Object containing one or more postgres query constraints
"""
def __init__(
... | winter-telescope/mirar | mirar/database/constraints.py | .py | 6e014d04dbfd9e8e | 7.54 | 11 |
#!/usr/bin/python
# Copyright: (c) 2023, Sergei Petrosian <spetrosi@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r"""
---
module: bootloader_facts
short_d... | linux-system-roles/bootloader | library/bootloader_facts.py | .py | 7826a289e27e4c1c | 7.52 | 10 |
# -*- coding: utf-8 -*-
# Copyright: (c) 2023, Sergei Petrosian <spetrosi@redhat.com>
# SPDX-License-Identifier: GPL-2.0-or-later
#
"""Unit tests for the bootloader_settings module"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import unittest
import bootloader_facts
impor... | linux-system-roles/bootloader | tests/unit/test_bootloader_facts.py | .py | 6b36b163433fd599 | 8.02 | 10 |
from typing import Any
import numpy as np
from scipy.linalg import eigh
from scipy.sparse import csr_matrix, diags, identity, kron, spmatrix
type PauliKron = dict[tuple[str, int] | tuple[str, int, int], spmatrix | np.ndarray]
# Set constants
sparse_X = csr_matrix(([1, 1], ([0, 1], [1, 0])), dtype=np.float64)
sparse_Z... | cameronperot/qbm | src/qbm/simulation/simulation.py | .py | f6c7dae949034b36 | 7.57 | 13 |
import json
import pickle
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import Any
import numpy as np
import pandas as pd
from numpy.random import MT19937, RandomState, SeedSequence
def compute_df_ensemble_stats(
dfs: Sequence[pd.DataFrame],
) -> dict[str, pd.DataFrame]:
... | cameronperot/qbm | src/qbm/utils/misc.py | .py | 4bada562929f1473 | 7.57 | 13 |
from collections.abc import Hashable, Sequence
import numpy as np
import pandas as pd
class PowerTransformer:
"""
Transforms data points that lie beyond the provided threshold by taking their
power (<1) to scale them closer to the mean.
"""
def __init__(
self,
df: pd.DataFrame,
... | cameronperot/qbm | src/qbm/utils/transformations.py | .py | 555d0a4d0fae3a8f | 7.57 | 13 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, eve... | linux-system-roles/ha_cluster | library/ha_cluster_info.py | .py | 731dbdbd795ea18e | 7.66 | 20 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3.9
from __future__ import absolute_import, division, print_function
# make ansible-test happy, e... | linux-system-roles/ha_cluster | library/pcs_api_v2.py | .py | c418e21cfc3d0019 | 7.66 | 20 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3.9
from __future__ import absolute_import, division, print_function
# make ansible-test happy, e... | linux-system-roles/ha_cluster | library/pcs_qdevice_certs.py | .py | ece0fea3bec01369 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/constraints_colocation.py | .py | acc0d06976b5f8b8 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/constraints_location.py | .py | 407d61e4600a059a | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/constraints_order.py | .py | b47b0317ccd99a5c | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/constraints_ticket.py | .py | 1749be42ec863500 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/nvset.py | .py | 636115fff0555baf | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/options.py | .py | 2b35e8424c0fea57 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/resource_defaults.py | .py | de6cd865ed9d5eb8 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/resources.py | .py | 0cebc7a3c0098202 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the modul... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/info/exporter_package/various.py | .py | 818606263b7993e6 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# make ansible-test happy, even though the module requires Python 3.9
from __future__ import absolute_import, division, print_function
# make ansible-test happy, even though the mod... | linux-system-roles/ha_cluster | module_utils/ha_cluster_lsr/pcs_api_v2_utils.py | .py | d2f2bd4841531298 | 7.66 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2025 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
from typing import List, Tuple
from unittest.mock import Mock
def get_fw_mock(
services: List[str], ports: List[Tuple[str, str]], exception: bool = False
) -> Mock:
"""
... | linux-system-roles/ha_cluster | tests/unit/firewall_mock.py | .py | ffae5954864d072c | 7.16 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# pylint: disable=missing-function-docstring
import json
import sys
from http.client import HTTPResponse
from unittest import mock
# Add paths to pcs bundled libraries to make Daci... | linux-system-roles/ha_cluster | tests/unit/fixture.py | .py | 4cdfc9f194cfc720 | 7.16 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# pylint: disable=missing-class-docstring
# pylint: disable=missing-function-docstring
from unittest import TestCase, mock
from .ha_cluster_info import ha_cluster_info, loader, moc... | linux-system-roles/ha_cluster | tests/unit/test_ha_cluster_info.py | .py | ac3f94aa72ec1a81 | 7.16 | 20 |
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Red Hat, Inc.
# Author: Tomas Jelinek <tojeline@redhat.com>
# SPDX-License-Identifier: MIT
# pylint: disable=missing-class-docstring
# pylint: disable=missing-function-docstring
import json
import os.path
from unittest import TestCase, mock
from .ha_cluster_info import h... | linux-system-roles/ha_cluster | tests/unit/test_ha_cluster_info_resources.py | .py | 96a1f5ecd3da2045 | 7.16 | 20 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""This charm library contains utilities to automatically forward your charm logs to a loki-push-api endpoint.
(yes! charm code, not workload code!)
If your charm isn't already related to Loki using any of the
consumers/... | canonical/loki-k8s-operator | lib/charms/loki_k8s/v0/charm_logging.py | .py | 1b54ff161a9ca9e6 | 7.56 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""This charm library contains utilities to automatically forward your charm logs to a loki-push-api endpoint.
(yes! charm code, not workload code!)
If your charm isn't already related to Loki using any of the
consumers/... | canonical/loki-k8s-operator | lib/charms/loki_k8s/v1/charm_logging.py | .py | b4a50c07cb1608c7 | 7.56 | 12 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Config builder for Loki Charmed Operator."""
import datetime
import os
from typing import Dict, List, Optional
# Paths in workload container
HTTP_LISTEN_PORT = 3100
LOKI_CONFIG_DIR = "/etc/loki"
LOKI_CONFIG = os.path.j... | canonical/loki-k8s-operator | src/config_builder.py | .py | f8fc3aac6b6450ef | 7.56 | 12 |
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import os
import shutil
from pathlib import Path
from typing import Dict
import jubilant
import pytest
import sh
import yaml
logger = logging.getLogger(__name__)
LOKI_PUSH_API_V1_PATH = Path("lib/charms/loki_k8s/v1/loki_push_api... | canonical/loki-k8s-operator | tests/integration/conftest.py | .py | cb75c6c04845b2db | 7.06 | 12 |
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import json
import logging
import subprocess
import urllib.request
from typing import List, Optional
from urllib.error import HTTPError
from urllib.parse import urljoin
import jubilant
import requests
import yaml
from tenacity import retry, sto... | canonical/loki-k8s-operator | tests/integration/helpers.py | .py | b86cb4220d85ae82 | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
#
# Learn more at: https://juju.is/docs/sdk
"""Log proxy test driver."""
import logging
from charms.loki_k8s.v1.loki_push_api import LogForwarder
from ops.charm import CharmBase
from ops.main import main
from ops.model i... | canonical/loki-k8s-operator | tests/integration/log-forwarder-tester/src/charm.py | .py | 931ce5535e2939ce | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
#
# Learn more at: https://juju.is/docs/sdk
"""Log proxy test driver."""
import logging
from charms.loki_k8s.v1.loki_push_api import LogProxyConsumer
from ops.charm import CharmBase
from ops.main import main
from ops.mod... | canonical/loki-k8s-operator | tests/integration/log-proxy-tester/src/charm.py | .py | 2c0701a3a0219a07 | 8.06 | 12 |
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""## Overview.
This document explains how to use the `JujuTopology` class to
create and consume topology information from Juju in a consistent manner.
The goal of the Juju topology is to uniquely identify a piece
of software running across any... | canonical/loki-k8s-operator | tests/integration/loki-tester/lib/charms/observability_libs/v0/juju_topology.py | .py | 1c11d859141fa5a3 | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""A Integration tester charm for Loki Operator."""
import logging
from typing import Dict, Optional
import logging_loki # type: ignore
from charms.loki_k8s.v1.loki_push_api import LokiPushApiConsumer
from cosl import J... | canonical/loki-k8s-operator | tests/integration/loki-tester/src/charm.py | .py | 8b4181f297934121 | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import jubilant
from helpers import get_alertmanager_alerts
logger = logging.getLogger(__name__)
def test_alert_rules_do_forward_to_alertmanager(
juju: jubilant.Juju,
loki_charm,
loki_resourc... | canonical/loki-k8s-operator | tests/integration/test_alert_rules_are_forwarded.py | .py | 520226302344d7fd | 7.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import jubilant
import pytest
from helpers import is_loki_up, juju_show_unit, loki_alerts, loki_rules
from tenacity import retry, stop_after_attempt, wait_exponential
logger = logging.getLogger(__name__)
... | canonical/loki-k8s-operator | tests/integration/test_alert_rules_fire.py | .py | fa115f7f208f176c | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import time
import jubilant
from helpers import is_loki_up, loki_api_query, oci_image
logger = logging.getLogger(__name__)
tester_resources = {
"workload-image": oci_image(
"./tests/integratio... | canonical/loki-k8s-operator | tests/integration/test_applications_send_logs.py | .py | c7a77f6fd64aec3f | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""This test module tests loki upgrade to validate schema migration from v11/boltdb to v12/tsdb.
Test Scenarios:
1. Deploy from Charmhub with revision 140 using v11/boltdb, then upgrade to local charm with v12/tsdb.
2. De... | canonical/loki-k8s-operator | tests/integration/test_boltdb_v11_to_tsdb_v12_migration.py | .py | 7bcb3e69f315ac44 | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from pathlib import Path
import jubilant
import sh
import yaml
from helpers import is_loki_up
logger = logging.getLogger(__name__)
METADATA = yaml.safe_load(Path("./charmcraft.yaml").read_text())
app_nam... | canonical/loki-k8s-operator | tests/integration/test_kubectl_delete.py | .py | c99cd460b482dd6e | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import jubilant
import yaml
from helpers import delete_pod, get_pebble_plan, loki_rules, oci_image
from tenacity import retry, stop_after_attempt, wait_exponential
logger = logging.getLogger(__name__)
@r... | canonical/loki-k8s-operator | tests/integration/test_log_forwarder.py | .py | 3936d8ddd34d4e51 | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import jubilant
from helpers import loki_alerts, oci_image
logger = logging.getLogger(__name__)
tester_resources = {
"workload-image": oci_image(
"./tests/integration/log-proxy-tester/charmcra... | canonical/loki-k8s-operator | tests/integration/test_log_proxy_alert_rules.py | .py | 912ef3a44e5082ef | 7.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import json
import logging
import jubilant
import pytest
from helpers import generate_log_file, loki_endpoint_request, oci_image
logger = logging.getLogger(__name__)
tester_resources = {
"workload-image": oci_image(... | canonical/loki-k8s-operator | tests/integration/test_log_proxy_send_logs.py | .py | 6e188fe67bcaccfc | 7.06 | 12 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from pathlib import Path
import jubilant
import yaml
from helpers import is_loki_up, loki_config, loki_services
logger = logging.getLogger(__name__)
METADATA = yaml.safe_load(Path("./charmcraft.yaml").rea... | canonical/loki-k8s-operator | tests/integration/test_loki_configs.py | .py | 2bc2a63a36e9e18c | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from pathlib import Path
import jubilant
import yaml
from helpers import is_loki_up, loki_rules
logger = logging.getLogger(__name__)
METADATA = yaml.safe_load(Path("./charmcraft.yaml").read_text())
app_n... | canonical/loki-k8s-operator | tests/integration/test_multiple_rule_providing_apps.py | .py | 0a4a2cbc4f3192f2 | 7.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
import jubilant
import pytest
import requests
from helpers import get_unit_address, loki_endpoint_request
from requests.auth import HTTPBasicAuth
logger = logging.getLogger(__name__)
LOKI = "loki"
GRAFANA... | canonical/loki-k8s-operator | tests/integration/test_self_monitoring.py | .py | 53915c73a5b16f94 | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""This test module tests loki upgrade with and without relations present.
1. Deploy the charm under test _from charmhub_.
2. Refresh with locally built charm.
3. Add all supported relations.
4. Refresh with locally built... | canonical/loki-k8s-operator | tests/integration/test_upgrade_charm.py | .py | e2b9a6b675a1ca8c | 7.06 | 12 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from pathlib import Path
import jubilant
import yaml
from helpers import is_loki_up, loki_rules
logger = logging.getLogger(__name__)
METADATA = yaml.safe_load(Path("./charmcraft.yaml").read_text())
app_na... | canonical/loki-k8s-operator | tests/integration/test_upgrade_charm_retains_alerts.py | .py | 3c4bf7749de5740a | 8.06 | 12 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from pathlib import Path
import jubilant
import yaml
from helpers import (
get_application_ip,
get_traces_patiently,
get_unit_address,
is_loki_up,
)
from minio import Minio
logger = logging... | canonical/loki-k8s-operator | tests/integration/test_workload_tracing.py | .py | f9319397e3cbc7ea | 7.06 | 12 |
#!/usr/bin/env python3
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
from datetime import datetime, timezone
from unittest.mock import patch
import yaml
from ops.pebble import Change, ChangeError, ChangeID
def tautology(*_, **__) -> bool:
return True
def pebble_change_error(message... | canonical/loki-k8s-operator | tests/unit/helpers.py | .py | 99c17284f35c10eb | 8.06 | 12 |
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
#
# Learn more about testing at: https://juju.is/docs/sdk/testing
import json
from dataclasses import replace
from http.client import HTTPMessage
from io import BytesIO
from unittest.mock import Mock, PropertyMock, patch
from urllib.error import... | canonical/loki-k8s-operator | tests/unit/test_charm.py | .py | 54e7991912fb4f80 | 7.06 | 12 |
import yaml
from ops.testing import Container, Exec, State, pebble
containers = [
Container(
name="loki",
can_connect=True,
layers={
"loki": pebble.Layer(
{
"services": {
"loki": {"startup": "enabled"},
... | canonical/loki-k8s-operator | tests/unit/test_config_reporting_enabled.py | .py | ba316062f15d2583 | 7.06 | 12 |
# Copyright 2020 Canonical Ltd.
# See LICENSE file for licensing details.
import json
import shutil
import tempfile
from dataclasses import replace
from pathlib import Path
from unittest.mock import patch
import pytest
import yaml
from charms.loki_k8s.v0.loki_push_api import AlertRules, CosTool, LokiPushApiConsumer
f... | canonical/loki-k8s-operator | tests/unit/test_consumer.py | .py | 9509fea59d180b58 | 7.06 | 12 |
"""
Example script for simple image analysis. By comparison of images
of the same well test, a tracer concentration can be determined.
"""
import os
from pathlib import Path
import darsia
# ! --- Source
class TailoredTracerAnalysis(darsia.TracerAnalysis):
"""Example of a tailored tracer analysis object."""
... | pmgbergen/DarSIA | examples/co2_analysis.py | .py | 785f7439b2e31f1a | 7.57 | 13 |
"""Test phase segmentation, taken from FluidFlower analysis conducted in the work
"Ferno et al., Room-scale CO2 injections in a physical reservoir model with faults
https://doi.org/10.48550/arXiv.2301.06397"
This test tests the FluidFlower presets, and in particular the workflow for CO2
phase segmentation analysis for... | pmgbergen/DarSIA | examples/phase_segmentation.py | .py | d1f820d657fa39a5 | 7.57 | 13 |
"""Module containing the base assistant class."""
from abc import ABC, abstractmethod
from typing import Any, Optional
import matplotlib.pyplot as plt
import numpy as np
import skimage
import darsia
class BaseAssistant(ABC):
"""Matplotlib based interactive assistant."""
def __init__(self, img: darsia.Imag... | pmgbergen/DarSIA | src/darsia/assistants/base_assistant.py | .py | cc0f3d70513183f9 | 7.57 | 13 |
"""Module for defining subregions interactively."""
from typing import Optional
import numpy as np
import darsia
class BoxSelectionAssistant(darsia.PointSelectionAssistant):
def __init__(self, img: darsia.Image, **kwargs) -> None:
super().__init__(img, **kwargs)
self.name = "Box selection assi... | pmgbergen/DarSIA | src/darsia/assistants/box_selection_assistant.py | .py | 47494956dab2193c | 7.57 | 13 |
"""Modulde for crop assistant.
Main prupose of the assistant is to produce input arguments for the
'crop' option of CurvatureCorrection.
"""
from typing import Optional, Union
import numpy as np
import darsia
class CropAssistant(darsia.PointSelectionAssistant):
"""Graphical assistant for cropping images as p... | pmgbergen/DarSIA | src/darsia/assistants/crop_assistant.py | .py | f544acebfb880cd1 | 7.57 | 13 |
"""Module containing a base implementation of an abstract correction."""
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Union
import numpy as np
import darsia
class BaseCorrection(ABC):
"""Abstract base correction, providing template for tailored corrections."""
def __call... | pmgbergen/DarSIA | src/darsia/corrections/basecorrection.py | .py | b9c0da6fdbda2250 | 7.57 | 13 |
"""Module for finding a colorchecker in an image."""
from typing import Literal
from warnings import warn
import colour_checker_detection
import numpy as np
import skimage
import darsia
ColorCheckerPosition = Literal["upper_right", "upper_left", "lower_right", "lower_left"]
def _reorient_colorchecker(
img: np... | pmgbergen/DarSIA | src/darsia/corrections/color/colorcheckerfinder.py | .py | 7dde74bc9ce76409 | 7.57 | 13 |
"""Module containing a Machine learning free color correction/calibration
based on the Classic Color Checker from calibrite / x-rite.
"""
import copy
import json
from abc import ABC
from pathlib import Path
from typing import Literal, Optional, Union
from warnings import warn
import colour
import cv2
import matplotli... | pmgbergen/DarSIA | src/darsia/corrections/color/colorcorrection.py | .py | 966408293989a25e | 7.57 | 13 |
"""Module containing dynamic illumination correction functionality."""
from pathlib import Path
from typing import Literal
import numpy as np
import scipy
import scipy.optimize
import skimage
import darsia
class DynamicIlluminationCorrection(darsia.BaseCorrection):
"""Class for illumination correction."""
... | pmgbergen/DarSIA | src/darsia/corrections/color/dynamicilluminationcorrection.py | .py | a122fb566951db66 | 7.57 | 13 |
"""Color corrections using ML-located color checker.
Module containing the color correction based on the Classic
Color Checker from calibrite / x-rite. The algorithms here
heavily use code from colour-science (see their github).
This includes some ML-based algorithms. Sometimes, the algorithms
are not able to detect t... | pmgbergen/DarSIA | src/darsia/corrections/color/experimentalcolorcorrection.py | .py | b92cc8d891c526bd | 7.57 | 13 |
"""Patchwise illumination correction module for images."""
from pathlib import Path
import cv2
import numpy as np
from matplotlib import pyplot as plt
import darsia
class PatchwiseIlluminationCorrection(darsia.BaseCorrection):
"""Class for performing patchwise illumination correction on images."""
def __i... | pmgbergen/DarSIA | src/darsia/corrections/color/patchwiseilluminationcorrection.py | .py | cf9dbf03967da4a9 | 7.57 | 13 |
"""Module for relative color balance correction based on global analysis."""
from pathlib import Path
from typing import Optional, Union
from warnings import warn
import numpy as np
import scipy.optimize
import darsia
class RelativeColorCorrection(darsia.BaseCorrection):
"""Relative color correction based on g... | pmgbergen/DarSIA | src/darsia/corrections/color/relativecolorcorrection.py | .py | 03836e1a6fa9b50a | 7.57 | 13 |
"""Module encoding standard transformations used in computer graphics.
These combine translation, rotation, and scaling. A class encodes the map itself,
including automatic determining. In addition, the actual correction object is
contained.
"""
from __future__ import annotations
from pathlib import Path
from typin... | pmgbergen/DarSIA | src/darsia/corrections/shape/affine.py | .py | 8dd5f30b5d169731 | 7.57 | 13 |
"""Module containing a local deformation correction.
This is essentially a correction object through wrappping
:mod:`darsia.DiffeomorphicImageRegistration`.
"""
from typing import Optional
import numpy as np
import darsia
class DeformationCorrection(darsia.BaseCorrection):
"""Patch-wise defined deformation c... | pmgbergen/DarSIA | src/darsia/corrections/shape/deformation.py | .py | c44f524600ed6d3b | 7.57 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.