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 |
|---|---|---|---|---|---|---|
"""Behavior-preserving smoke test for PredictBOPOs.
Runs every public method of PredictBOPOs on one train/test split of
chd_49 and pickles the outputs to ``<out_dir>/smoke.pkl``. Run before
and after the refactor and diff the pickles.
"""
import argparse
import hashlib
import pickle
from pathlib import Path
import n... | hxtruong6/pre-order-for-mlc | scripts/smoke_predict_bopos.py | .py | e62c558aaaeef26c | 7.3 | 3 |
"""Train the ECC (Ensemble of Classifier Chains) baseline.
Standalone, additive script. Loads datasets via Datasets4Experiments using the
same splits / seed as scripts/train.py so the ECC results are directly
comparable to existing BR/CC/CLR/BOPOs pickles.
CLI:
python scripts/train_ecc.py --dataset <key> --result... | hxtruong6/pre-order-for-mlc | scripts/train_ecc.py | .py | eedd3748940ecd96 | 7.3 | 3 |
# -*- coding: utf-8 -*-
import queue
import threading
import time
# 自定义无缓存读视频类
class VideoCaptureQueue:
"""Customized VideoCapture, always read last frame"""
def __init__(self, *args, **kwargs):
import cv2
# "camera_id" is a int type id or string name
self.cap = cv2.VideoCapture(*arg... | farfarfun/funmodel | funmodel/utils/capture/queue.py | .py | e0a2fd19b9883576 | 7 | 0 |
# Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, includi... | ansys/pymechanical-stubs | scripts/03-create-toc-from-html-mechanical.py | .py | e90e38d49f50c311 | 7.3 | 3 |
# Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, includi... | ansys/pymechanical-stubs | scripts/05-remove-link-in-heading.py | .py | a23276c6e267cb08 | 7.3 | 3 |
# Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, includi... | ansys/pymechanical-stubs | scripts/fix-href-html.py | .py | cd38b0de563765c0 | 7.3 | 3 |
# Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, includi... | ansys/pymechanical-stubs | scripts/fix-href-md.py | .py | 37d43e6fbef361d9 | 7.3 | 3 |
# Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, includi... | ansys/pymechanical-stubs | scripts/replace-windows-apostrophes.py | .py | c4569de711ec577a | 7.3 | 3 |
# Copyright (C) 2023 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, includi... | ansys/pymechanical-stubs | src/ansys/mechanical/stubs/stub_generator/create_files.py | .py | 5c9fd2e17d922f57 | 7.3 | 3 |
#!/usr/bin/env python3
"""
Thread-safe SettingsManager example
This example demonstrates how to use the new thread-safe SettingsManager
in a multi-threaded environment.
"""
import threading
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from typing import Any
from pydantic_settings import... | kiarina/pydantic-settings-manager | examples/thread_safe/thread_safe_example.py | .py | a0c984a1b511a182 | 7 | 0 |
from pydantic import BaseModel
from pydantic_core import ErrorDetails
from .._models.settings_manager import SettingsManager
from .generate_settings_fields_yaml_lines import (
FieldError,
generate_settings_fields_yaml_lines,
)
from .resolve_module_config_path import resolve_module_config_path
def build_user_... | kiarina/pydantic-settings-manager | pydantic_settings_manager/_operations/build_user_config_error_message.py | .py | 8e48fd142d5ffb31 | 7 | 0 |
from __future__ import annotations
import sys
from importlib import import_module
from .._models.settings_manager import SettingsManager
def resolve_module_config_path(
manager: SettingsManager,
*,
manager_name: str = "settings_manager",
) -> str | None:
"""Resolve the shallowest public module path ... | kiarina/pydantic-settings-manager | pydantic_settings_manager/_operations/resolve_module_config_path.py | .py | b361b0ab240056e3 | 7 | 0 |
"""
abort_multipart_uploads.py
Utility script to abort unclosed multipart uploads in an S3 bucket.
Partially generated by GitHub Copilot.
"""
import json
import subprocess
import sys
def list_multipart_uploads(bucket):
"""
List unclosed multipart uploads in an S3 bucket.
Parameters
----------
bu... | NASA-PDS/data-upload-manager | src/pds/ingress/client/abort_multipart_uploads.py | .py | 65b87e98471a6d18 | 7.15 | 1 |
#!/usr/bin/env python3
"""
=================
pds_status_client
=================
Client side script used to interact with the DUM Ingress Status service in AWS.
"""
import argparse
import json
import os
from http import HTTPStatus
import requests
from pds.ingress import __version__
from pds.ingress.util.auth_util imp... | NASA-PDS/data-upload-manager | src/pds/ingress/client/pds_status_client.py | .py | a8359b445da39703 | 7.15 | 1 |
"""
=================
pds_status_app.py
=================
Lambda function used to status an Ingress request based on a user-provided
manifest. For each file included in a provided manifest, this function will
derive the Ingress status of said file in S3 and return a report to the user.
"""
import concurrent.futures
im... | NASA-PDS/data-upload-manager | src/pds/ingress/service/pds_status_app.py | .py | 5986cd74611b0f01 | 7.15 | 1 |
#!/usr/bin/env python3
"""
===================
sync_s3_metadata.py
===================
Lambda function which updates existing objects in S3 with metdata typically
added by either the DUM ingress client or the rclone utility.
"""
import argparse
import calendar
import concurrent.futures
import logging
import os
from da... | NASA-PDS/data-upload-manager | src/pds/ingress/service/sync_s3_metadata.py | .py | 5932b42d0bda360a | 7.15 | 1 |
"""
===============
backoff_util.py
===============
Module containing functions related to utilization of the backoff module for
automatic backoff/retry of HTTP requests.
"""
import importlib
import multiprocessing
import random
from contextlib import contextmanager
from http import HTTPStatus
import requests_mock
f... | NASA-PDS/data-upload-manager | src/pds/ingress/util/backoff_util.py | .py | 0fd134ebd5691e0c | 7.15 | 1 |
"""
==============
config_util.py
==============
Module containing functions for parsing config files used by the
Ingress client and service.
"""
import configparser
import os
from fnmatch import fnmatchcase
from importlib.resources import files
from os.path import join
from urllib.parse import urlparse
import boto3... | NASA-PDS/data-upload-manager | src/pds/ingress/util/config_util.py | .py | 9f879f29b7a0a2ef | 7.15 | 1 |
"""
===========
log_util.py
===========
Module containing functions related to logging and set up of the logger used
with the ingress client.
"""
import json
import logging
import re
import sys
import tempfile
from datetime import datetime
from logging.handlers import BufferingHandler
from .config_util import Config... | NASA-PDS/data-upload-manager | src/pds/ingress/util/log_util.py | .py | 6eb361ec23817c12 | 7.15 | 1 |
"""
============
node_util.py
============
Module containing functions for working with PDS Node identifiers.
"""
class NodeUtil:
"""Provides methods to validate PDS Node identifiers."""
node_id_to_long_name = {
"atm": "Atmospheres",
"eng": "Engineering",
"geo": "Geosciences",
... | NASA-PDS/data-upload-manager | src/pds/ingress/util/node_util.py | .py | b4b88fbeee2c837c | 7.15 | 1 |
"""
==============
report_util.py
==============
Module containing functions related to output of various report files used
to track status of a DUM upload request.
"""
import json
import multiprocessing
import os
import time
from datetime import datetime
from datetime import timezone
from pds.ingress.util.log_util ... | NASA-PDS/data-upload-manager | src/pds/ingress/util/report_util.py | .py | b4f7610d1a5d29a6 | 7.15 | 1 |
import json
import os
import unittest
from datetime import datetime
from datetime import timezone
from importlib.resources import files
from unittest.mock import MagicMock
from unittest.mock import patch
import botocore.client
import botocore.exceptions
import pds.ingress.service.pds_status_app
import pds.ingress.util... | NASA-PDS/data-upload-manager | tests/pds/ingress/service/test_pds_status_app.py | .py | c26f453344f3a3af | 7.65 | 1 |
#!/usr/bin/env python3
import unittest
from unittest.mock import patch
import pds.ingress.util.auth_util
from pds.ingress.util.auth_util import AuthUtil
class MockCognitoClient:
"""Mock implementation for the boto3 Cognito client class"""
def initiate_auth(self, AuthFlow, AuthParameters, ClientId):
... | NASA-PDS/data-upload-manager | tests/pds/ingress/util/test_auth_util.py | .py | f303c79fb2c564fd | 7.65 | 1 |
#!/usr/bin/env python3
import json as json_module
import os
import unittest
from http import HTTPStatus
from unittest.mock import MagicMock
from unittest.mock import patch
import pds.ingress.util.log_util as log_util
import requests
from pds.ingress.util.config_util import ConfigUtil
from pds.ingress.util.node_util im... | NASA-PDS/data-upload-manager | tests/pds/ingress/util/test_log_util.py | .py | 157b80f0791f5ec7 | 7.65 | 1 |
#!/usr/bin/env python3
import os
import tempfile
import unittest
from importlib.resources import files
from os.path import abspath
from os.path import join
from pathlib import Path
from pds.ingress.util.path_util import PathUtil
from pds.ingress.util.progress_util import close_path_progress_bar
from pds.ingress.util.p... | NASA-PDS/data-upload-manager | tests/pds/ingress/util/test_path_util.py | .py | d5d81a8f2dd40505 | 7.65 | 1 |
"""Session authentication that also protects anonymous unsafe requests."""
from rest_framework.authentication import SessionAuthentication
from rest_framework.exceptions import PermissionDenied
from rest_framework.request import Request
class CsrfRejected(PermissionDenied):
"""Identify CSRF rejection without exp... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/authentication.py | .py | 86acbec8f7910876 | 7 | 0 |
"""Admin forms for the email-based learner account."""
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from .models import LearnerAccount
class LearnerAccountCreationForm(UserCreationForm):
"""Create a learner account through Django admin."""
class Meta(UserCreationForm.Meta):
... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/forms.py | .py | 59ff2aa34158e33b | 7 | 0 |
"""Verified Google identity resolution and explicit account linking."""
from dataclasses import dataclass
from enum import StrEnum
from typing import Any
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.db import IntegrityError, transaction
from .manage... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/google_identity.py | .py | 2f6ff03940ef59fb | 7 | 0 |
"""Google OpenID Connect client configuration for learner authentication."""
from authlib.integrations.django_client import OAuth
from django.conf import settings
GOOGLE_OPENID_CONFIGURATION_URL = (
"https://accounts.google.com/.well-known/openid-configuration"
)
class GoogleOAuthUnavailable(RuntimeError):
... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/google_oauth.py | .py | fc88f74c3bf0d200 | 7 | 0 |
"""Account manager with one canonical email identity."""
from typing import Any
from django.contrib.auth.base_user import BaseUserManager
EMAIL_MAX_LENGTH = 254
class LearnerAccountManager(BaseUserManager):
"""Create learners whose normalized email is their sign-in identity."""
use_in_migrations = True
... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/managers.py | .py | 224f9ec2c3647c40 | 7 | 0 |
"""Clean-rebuild learner account model."""
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.functions import Lower
from django.utils import timezone
from .managers import LearnerAccountManage... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/models.py | .py | 3a2515acc95a4d81 | 7 | 0 |
"""Password-recovery delivery for clean-rebuild learner accounts."""
import logging
from urllib.parse import urlencode
from django.conf import settings
from django.contrib.auth import password_validation
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.core.exceptions import ValidationEr... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/password_recovery.py | .py | 18972ad6a8012d13 | 7 | 0 |
"""OpenAPI description for the stricter session authentication class."""
from django.conf import settings
from drf_spectacular.extensions import OpenApiAuthenticationExtension
class CsrfEnforcedSessionScheme(OpenApiAuthenticationExtension):
"""Publish the normal Django session cookie authentication scheme."""
... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/schema.py | .py | cb2535bb8022c96c | 7 | 0 |
"""Typed request and response contracts for learner accounts."""
from typing import Any
from django.contrib.auth import get_user_model, password_validation
from django.core.exceptions import ValidationError as DjangoValidationError
from django.db import IntegrityError, transaction
from rest_framework import serialize... | Aequor29/Crack-GRE-Vocab | crackGreVocab/accounts/serializers.py | .py | 906d31682abb6b78 | 7 | 0 |
"""Public response contracts for the foundational API."""
from rest_framework import serializers
class ServiceIndexSerializer(serializers.Serializer):
"""Describe the database-independent service document."""
service = serializers.CharField()
class ReadinessSerializer(serializers.Serializer):
"""Descr... | Aequor29/Crack-GRE-Vocab | crackGreVocab/api/serializers.py | .py | 6e5ac3fbdb8f8e25 | 7 | 0 |
"""Foundational API views that do not depend on product data."""
from django.db import Error, connection
from drf_spectacular.utils import extend_schema
from rest_framework.permissions import AllowAny
from rest_framework.renderers import JSONRenderer
from rest_framework.request import Request
from rest_framework.respo... | Aequor29/Crack-GRE-Vocab | crackGreVocab/api/views.py | .py | 2abb09fe87629c02 | 7 | 0 |
"""Strict environment parsing for Django settings."""
import os
from collections.abc import Iterable
from urllib.parse import urlparse
from django.core.exceptions import ImproperlyConfigured
_TRUE_VALUES = frozenset({"1", "true", "yes", "on"})
_FALSE_VALUES = frozenset({"0", "false", "no", "off"})
def required_env... | Aequor29/Crack-GRE-Vocab | crackGreVocab/crackGreVocab/config.py | .py | 5272d8f5333cecce | 7 | 0 |
"""ORM locking and writes for backend-planned Study Sessions."""
from collections.abc import Sequence
from datetime import datetime
from uuid import UUID
from accounts.models import LearnerAccount
from vocabulary.models import CorpusEntry, CorpusVersion
from .models import (
LearnerWordState,
RecallAnswer,
... | Aequor29/Crack-GRE-Vocab | crackGreVocab/study/persistence.py | .py | 9f56b086198b9bc8 | 7 | 0 |
"""Read-only ORM queries for the Study domain."""
from datetime import datetime
from uuid import UUID
from accounts.models import LearnerAccount
from django.db.models import Prefetch, QuerySet
from vocabulary.models import CorpusEntry, CorpusVersion
from .models import LearnerWordState, RecallAnswer, StudySession, S... | Aequor29/Crack-GRE-Vocab | crackGreVocab/study/selectors.py | .py | 60f0148384015561 | 7 | 0 |
import uvicorn
import onnxruntime
import numpy as np
from fastapi import FastAPI, UploadFile, File
from PIL import Image
from io import BytesIO
from request_body import EmotionResponse
def preprocess_image(bytes_io) -> np.array:
"""
Opens and prepares image for the model.
It mimics original torch transf... | wpartycja/facial-emotion-recognition | app_feraina/server/server.py | .py | 8d6af1fe678d2fd2 | 7.15 | 1 |
import os
import json
import shutil
# @TODO: wez to jakos ladnie
train_path = '../../datasets/AffectNet/train_set/images'
val_path = '../../datasets/AffectNet/val_set/images'
dest = '../../datasets/AffectNet_clean'
def order_dataset(csv_path: str, json_path_train: str, json_path_val: str) -> None:
"""
reading... | wpartycja/facial-emotion-recognition | dataset_prep/affectnet_arrange.py | .py | 4e64ed0ed49e675c | 7.15 | 1 |
import torch
import torchvision.transforms as T
import torchvision.datasets
from model import Model
import argparse
from networks.dan import DAN
from sklearn.metrics import classification_report
import torch.nn as nn
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import confusion_matrix, Confus... | wpartycja/facial-emotion-recognition | models/DAN/evaluate.py | .py | d5d08ab98957dcf0 | 7.15 | 1 |
import torch
class ImbalancedDatasetSampler(torch.utils.data.sampler.Sampler):
"""Samples elements randomly from a given list of indices for imbalanced dataset
Arguments:
indices (list, optional): a list of indices
num_samples (int, optional): number of samples to draw
"""
d... | wpartycja/facial-emotion-recognition | models/DMUE/datasets/sampler.py | .py | c6c285cf57f18752 | 7.15 | 1 |
from typing import Optional
from airflow.providers.cncf.kubernetes.operators.pod import (
KubernetesPodOperator,
)
from airflow.providers.cncf.kubernetes.utils.xcom_sidecar import (
PodDefaults,
)
from analytical_platform.compute_profiles import get_compute_profile
from kubernetes.client import models as k8s_m... | ministryofjustice/analytical-platform-airflow | airflow/analytical_platform/standard_operator.py | .py | cc10c8e852074f19 | 7.39 | 5 |
#!/usr/bin/env python3
"""
GitHub App Authentication Helper
This script generates an installation access token from GitHub App credentials
and outputs it to stdout for use in bash scripts.
Environment Variables:
githubAppId: GitHub App ID
githubAppInstallationId: GitHub App Installation ID
githubAppPrivat... | ministryofjustice/analytical-platform-airflow | scripts/github/auth_helper.py | .py | 3ed6950a5709cf9b | 7.39 | 5 |
#!/usr/bin/env python3
"""
Unit tests for workflows.
Ensures that all workflows can be successfully generated and validated.
These tests will be run in CI whenever a change to the scripts dir are detected, to catch any errors
with the newly generated workflows before they are deployed to Airflow.
"""
import sys
import ... | ministryofjustice/analytical-platform-airflow | tests/test_workflows.py | .py | ef66370fb54acef3 | 7.89 | 5 |
import os, argparse, json
import numpy as np
import joblib
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.utils.class_weight import compute_sample_weight
from sklearn.metrics import accuracy_score, roc_auc_score
from src.Backtester import Backt... | mcgunit/sequencePredictor | TrainMetaLearner.py | .py | 23958ef54707eee4 | 7 | 0 |
import numpy as np
from collections import defaultdict
class Baselines:
@staticmethod
def random_ticket(min_number, max_number, draw_size):
return sorted(
np.random.choice(
np.arange(min_number, max_number + 1),
size=draw_size,
replace=False
... | mcgunit/sequencePredictor | src/Baselines.py | .py | e48d3251b1db85ae | 7 | 0 |
import os, sys
from catboost import CatBoostClassifier
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = os.path.join(parent_dir, 'src')
if current_dir not in sys.path:
sys.path.append(current_dir)
if src_dir not in sys.path:
... | mcgunit/sequencePredictor | src/CatBoost.py | .py | 7dbd339a6bd7aeec | 7 | 0 |
import os
import sys
from collections import Counter
# Dynamically adjust the import path for Helpers
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = os.path.join(parent_dir, 'src')
if current_dir not in sys.path:
sys.path.appen... | mcgunit/sequencePredictor | src/HybridStatisticalModel.py | .py | 826ef4d4cf7c9f51 | 7 | 0 |
import os, sys
import numpy as np
from scipy.stats import laplace
from scipy.special import softmax
from collections import defaultdict
# Dynamically adjust the import path for Helpers
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = ... | mcgunit/sequencePredictor | src/LaplaceMonteCarlo.py | .py | 6b340db1da4162c2 | 7 | 0 |
import os, sys
import lightgbm as lgb
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = os.path.join(parent_dir, 'src')
if current_dir not in sys.path:
sys.path.append(current_dir)
if src_dir not in sys.path:
sys.path.append(s... | mcgunit/sequencePredictor | src/LightGBM.py | .py | f0cdea04ab6dc32d | 7 | 0 |
import os
import sys
import numpy as np
import scipy.special
from collections import defaultdict
from Helpers import Helpers
# Dynamically adjust the import path for Helpers
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = os.path.joi... | mcgunit/sequencePredictor | src/MarkovBayesian.py | .py | 0547c518c321a21e | 7 | 0 |
import os
import sys
import random
from collections import defaultdict
from Helpers import Helpers
from MarkovBayesian import MarkovBayesian
# Dynamically adjust the import path for Helpers
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_d... | mcgunit/sequencePredictor | src/MarkovBayesianEnhanched.py | .py | a221cc33ab695d33 | 7 | 0 |
import os, sys, random
import numpy as np
from collections import Counter, defaultdict
from PoissonMonteCarlo import PoissonMonteCarlo
from Markov import Markov
# Dynamically adjust the import path for Helpers
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_di... | mcgunit/sequencePredictor | src/PoissonMarkov.py | .py | e83799bc196eeb7a | 7 | 0 |
import os,sys
import numpy as np
from scipy.stats import poisson
from scipy.special import softmax
from collections import defaultdict
# Dynamically adjust the import path for Helpers
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = o... | mcgunit/sequencePredictor | src/PoissonMonteCarlo.py | .py | 3c543d0ab2b5eab8 | 7 | 0 |
import os, sys
import xgboost as xgb
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
src_dir = os.path.join(parent_dir, 'src')
if current_dir not in sys.path:
sys.path.append(current_dir)
if src_dir not in sys.path:
sys.path.append(sr... | mcgunit/sequencePredictor | src/XGBoost.py | .py | d6c06c552302e78b | 7 | 0 |
"""Common testing fixtures."""
import json
import os
import pathlib
import shutil
import subprocess
import tempfile
from collections.abc import Callable, Generator
from contextlib import contextmanager
from typing import Any
import pytest
from google import auth
from google.cloud import compute_v1
DEFAULT_PREFIX = "... | memes/terraform-google-multi-region-private-network | tests/conftest.py | .py | 4d76fa55a4ae2dea | 7.5 | 0 |
"""Test fixture for single-region deployment."""
import pathlib
from collections.abc import Callable, Generator
from typing import Any
import pytest
from google.cloud import compute_v1
from .conftest import run_tofu_in_workspace
FIXTURE_NAME = "single-region"
FIXTURE_LABELS = {
"fixture": FIXTURE_NAME,
}
@pyt... | memes/terraform-google-multi-region-private-network | tests/test_single_region.py | .py | 01d7263b9d092941 | 7.5 | 0 |
from django.http import HttpRequest
from orders.models import Order
from robots.models import Robot
from customers.models import Customer
def _validate_new_order_request(request: HttpRequest) -> dict[str, str] | None:
"""Return valid data for creating a new order from POST request as `dict`.
If something is ... | JustKappaMan/R4C-Interview-Task | src/orders/utils/factory.py | .py | b489144ff337dca6 | 7 | 0 |
from django.urls import reverse
from django.shortcuts import render, redirect
from django.http import HttpRequest, HttpResponse
from django.views.decorators.http import require_http_methods, require_GET
from orders.utils.factory import create_new_order
@require_http_methods(("GET", "POST"))
def new_order_view(reques... | JustKappaMan/R4C-Interview-Task | src/orders/views.py | .py | e873b00e5ead3077 | 7 | 0 |
from re import fullmatch
from datetime import datetime
from django.db import models
from django.utils import timezone
from django.db.models import Count
class RobotsManager(models.Manager):
def models(self) -> tuple[str]:
"""Get unique `Robot.model` values"""
return tuple(self.values_list("model"... | JustKappaMan/R4C-Interview-Task | src/robots/models.py | .py | 92aa158af10798a0 | 7 | 0 |
import json
from datetime import datetime as dt
from django.utils import timezone as tz
from django.http import HttpRequest
from robots.models import Robot
def _json_request_to_dict(request: HttpRequest) -> dict | None:
"""Return valid JSON from `request.body` as `dict`.
If JSON isn't valid or doesn't use U... | JustKappaMan/R4C-Interview-Task | src/robots/utils/factory.py | .py | bbd44d2e65d85d2e | 7 | 0 |
from pathlib import Path
from django.conf import settings
from django.utils import timezone as tz
from openpyxl import Workbook
from openpyxl.styles import Alignment, Font
from robots.models import Robot
def _get_last_week_stats() -> dict:
"""Return summary of robot production totals for the last week"""
d... | JustKappaMan/R4C-Interview-Task | src/robots/utils/xlsx.py | .py | 61f6076a4a006073 | 7 | 0 |
import json
from http import HTTPStatus
from django.urls import reverse
from django.core import serializers
from django.shortcuts import render, redirect
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_GET
from django.http import HttpRequest, HttpResponse, JsonResp... | JustKappaMan/R4C-Interview-Task | src/robots/views.py | .py | c92cbce0130baaae | 7 | 0 |
#!/usr/bin/env python3
"""
Copyright 2024 carlkidcrypto, All rights reserved.
A python3 class designed to fetch data from Purple Air's new API.
https://api.purpleair.com/#api-welcome
"""
from purpleair_api.PurpleAirAPIHelpers import debug_log, send_url_get_request
from purpleair_api.PurpleAirAPIError import PurpleAir... | carlkidcrypto/purpleair_api | purpleair_api/PurpleAirAPI.py | .py | 01b6bda4a749f9a2 | 7.35 | 4 |
#!/usr/bin/env python3
"""
Copyright 2024 carlkidcrypto, All rights reserved.
A python3 class designed to fetch data from Purple Air's new API.
https://api.purpleair.com/#api-welcome
"""
class PurpleAirAPIError(Exception):
"""
Custom Exception for our PurpleAirAPI class.
"""
def __init__(self, messa... | carlkidcrypto/purpleair_api | purpleair_api/PurpleAirAPIError.py | .py | 3e0019c766a9cb4d | 7.35 | 4 |
#!/usr/bin/env python3
"""
Copyright 2024 carlkidcrypto, All rights reserved.
"""
import unittest
import sys
sys.path.append("../")
from purpleair_api.PurpleAirAPIConstants import (
PRINT_DEBUG_MSGS,
ERROR_CODES_LIST,
SUCCESS_CODE_LIST,
ACCEPTED_FIELD_NAMES_DICT,
)
class PurpleAirAPIConstantsTest(... | carlkidcrypto/purpleair_api | tests/test_purpleair_api_constants.py | .py | 21957c7e7d22b5a7 | 7.85 | 4 |
#!/usr/bin/env python3
"""
Copyright 2023 carlkidcrypto, All rights reserved.
"""
import unittest
import sys
sys.path.append("../")
from purpleair_api.PurpleAirAPIError import PurpleAirAPIError
class PurpleAirAPIErrorTest(unittest.TestCase):
def test_custom_error(self):
"""
Test that our custo... | carlkidcrypto/purpleair_api | tests/test_purpleair_api_error.py | .py | d9019146eaca24be | 7.85 | 4 |
from __future__ import with_statement
import logging
from logging.config import fileConfig
from alembic import context
from flask import current_app
from sqlalchemy_continuum import versioning_manager
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = co... | bcgov/EPIC.compliance | compliance-api/migrations/env.py | .py | 0dbf864a21ce74c1 | 7.24 | 2 |
"""remove exemption_order_number field
Revision ID: 026779d28e0c
Revises: 5291fcced72e
Create Date: 2025-07-24 15:18:33.731676
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '026779d28e0c'
down_revision = '5291fcced72e'
branch_labels = None
depends_on = None
... | bcgov/EPIC.compliance | compliance-api/migrations/versions/026779d28e0c_remove_exemption_order_number_field.py | .py | 4ee58618a03d4536 | 7.24 | 2 |
"""remove complaint req eac and schedule b details tables
Revision ID: 06fdb92a1550
Revises: 3270e1234eb0
Create Date: 2025-01-27 10:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '06fdb92a1550'
down_revision = '3270e1234eb0'
branch_labels = None
... | bcgov/EPIC.compliance | compliance-api/migrations/versions/06fdb92a1550_remove_complaint_req_eac_and_schedule_b_details_tables.py | .py | 52d15ecae616b54c | 7.24 | 2 |
"""enforcement_action change+restorative justice option
Revision ID: 0f766f32027e
Revises: ec9d056ba2f9
Create Date: 2025-08-20 10:23:15.983007
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0f766f32027e'
down_revision = 'ec9d056ba2f9'
branch_labels = None
de... | bcgov/EPIC.compliance | compliance-api/migrations/versions/0f766f32027e_enforcement_action_change_restorative_.py | .py | 94e3054966afdf35 | 7.24 | 2 |
"""approval status changes+ approved_date in inspection
Revision ID: 1637128b4b97
Revises: d17621c35d33
Create Date: 2025-06-17 13:23:40.034314
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1637128b4b97'
down_revision = 'd17621c35d33'
branch_labels = None
de... | bcgov/EPIC.compliance | compliance-api/migrations/versions/1637128b4b97_approval_status_changes_approved_date_.py | .py | b624596107183725 | 7.24 | 2 |
"""inspection_images table creation
Revision ID: 199147664d8e
Revises: ff7d002a8a12
Create Date: 2025-02-18 10:11:33.606897
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '199147664d8e'
down_revision = 'ff7d002a8a12'
branch_labels = None
depends_on = None
de... | bcgov/EPIC.compliance | compliance-api/migrations/versions/199147664d8e_inspection_images_table_creation.py | .py | bf9bd89a374fb5e1 | 7.74 | 2 |
"""Add First Nations Alliance complaint source and alliance_name in complaints
Revision ID: 1ab7e8f3afee
Revises: df8eb8203cd6
Create Date: 2025-12-03 10:23:15.983007
"""
from alembic import op
from compliance_api.models.type import EncryptedType
import sqlalchemy as sa
from datetime import datetime
# revision iden... | bcgov/EPIC.compliance | compliance-api/migrations/versions/1ab7e8f3afee_add_complaint_source.py | .py | 3aae613db20736d4 | 7.24 | 2 |
"""adding address line 2 in department
Revision ID: 1c5786563579
Revises: bfc8625ce5ce
Create Date: 2025-04-21 19:36:54.347271
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1c5786563579'
down_revision = 'bfc8625ce5ce'
branch_labels = None
depends_on = None
... | bcgov/EPIC.compliance | compliance-api/migrations/versions/1c5786563579_adding_address_line_2_in_department.py | .py | 3812ee97e1453a49 | 7.24 | 2 |
"""source contact table
Revision ID: 1c72d4a3fcb7
Revises: 583a92eaa5f1
Create Date: 2024-09-25 15:46:45.013940
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from compliance_api.models.type import EncryptedType
# revision identifiers, used by Alembic.
revision = '1c72d4... | bcgov/EPIC.compliance | compliance-api/migrations/versions/1c72d4a3fcb7_source_contact_table.py | .py | 95aff8f16299f22d | 7.24 | 2 |
"""enforcement requirement map
Revision ID: 20afe60273fb
Revises: 6c3b6755e2dc
Create Date: 2025-01-10 11:12:08.390578
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '20afe60273fb'
down_revision = '6c3b6755e2dc'
branch_labels = None
depends_on = None
def upg... | bcgov/EPIC.compliance | compliance-api/migrations/versions/20afe60273fb_enforcement_requirement_map.py | .py | 89d03089fab098d4 | 7.24 | 2 |
"""
Revision ID: 20bcb68bc2ac
Revises:
Create Date: 2024-06-27 14:22:33.838724
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '20bcb68bc2ac'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alem... | bcgov/EPIC.compliance | compliance-api/migrations/versions/20bcb68bc2ac_.py | .py | 7dd8b5399494bddf | 7.24 | 2 |
"""project_status change in inspection
Revision ID: 20e336b523d9
Revises: cde897a20139
Create Date: 2024-11-18 11:37:57.451442
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '20e336b523d9'
down_revision = 'cde897a20139... | bcgov/EPIC.compliance | compliance-api/migrations/versions/20e336b523d9_project_status_change_in_inspection.py | .py | e2accdbc7c462507 | 7.74 | 2 |
"""requirement_source_name_change
Revision ID: 21278058610c
Revises: e8129db0036b
Create Date: 2024-10-07 16:13:06.721179
"""
from datetime import datetime
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '21278058610c'
down_revision = 'e8129db0036b'
branch_labels =... | bcgov/EPIC.compliance | compliance-api/migrations/versions/21278058610c_requirement_source_name_change.py | .py | b3aa681f00ddd574 | 7.24 | 2 |
"""adding topic and req desc in complaint
Revision ID: 3270e1234eb0
Revises: c8cc683f4019
Create Date: 2025-08-01 11:28:27.125817
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3270e1234eb0'
down_revision = 'c8cc683f4019'
branch_labels = None
depends_on = Non... | bcgov/EPIC.compliance | compliance-api/migrations/versions/3270e1234eb0_adding_topic_and_req_desc_in_complaint.py | .py | 91088e4d4b734537 | 7.24 | 2 |
"""case_file_unique_constraint
Revision ID: 36a31040a452
Revises: c353afd11883
Create Date: 2024-12-09 11:24:09.962154
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '36a31040a452'
down_revision = 'c353afd11883'
branch_labels = None
depends_on = None
def upg... | bcgov/EPIC.compliance | compliance-api/migrations/versions/36a31040a452_case_file_unique_constraint.py | .py | 621948ebb497a100 | 7.24 | 2 |
"""create_document_jobs_table
Revision ID: 36db02e529a3
Revises: 1ab7e8f3afee
Create Date: 2025-12-15 10:26:59.072443
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '36db02e529a3'
down_revision = '1ab7e8f3afee'
branch_labels = None
depends_on = None
def upgr... | bcgov/EPIC.compliance | compliance-api/migrations/versions/36db02e529a3_create_document_jobs_table.py | .py | d249265985da59f3 | 7.24 | 2 |
"""Remove closed as note status
Revision ID: 3aa492aa47db
Revises: 91f76d883f32
Create Date: 2025-02-06 13:22:09.682441
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3aa492aa47db'
down_revision = '91f76d883f32'
branch_labels = None
depends_on = None
def up... | bcgov/EPIC.compliance | compliance-api/migrations/versions/3aa492aa47db_remove_closed_as_note_status.py | .py | e390daaf6c80907e | 7.24 | 2 |
"""adding more number fields in source details
Revision ID: 3af167e3a79f
Revises: 47b26a21801c
Create Date: 2025-07-08 15:18:47.524447
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3af167e3a79f'
down_revision = '47b26a21801c'
branch_labels = None
depends_on ... | bcgov/EPIC.compliance | compliance-api/migrations/versions/3af167e3a79f_adding_more_number_fields_in_source_.py | .py | 3ea111d7fc6b5dd8 | 7.24 | 2 |
"""removing inspection_req_detail_image unique index
Revision ID: 3d9e96992c02
Revises: e6d2d06d4b65
Create Date: 2025-10-15 12:58:09.415778
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3d9e96992c02'
down_revision = 'e6d2d06d4b65'
branch_labels = None
depen... | bcgov/EPIC.compliance | compliance-api/migrations/versions/3d9e96992c02_removing_inspection_req_detail_image_.py | .py | 5e31b84140554731 | 7.74 | 2 |
"""adding progress column warning letter
Revision ID: 3e71292c2eaf
Revises: 970586edecc4
Create Date: 2025-05-28 17:18:35.757384
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3e71292c2eaf'
down_revision = '970586edecc4'
branch_labels = None
depends_on = None... | bcgov/EPIC.compliance | compliance-api/migrations/versions/3e71292c2eaf_adding_progress_column_warning_letter.py | .py | 161cb63f0beb7ba3 | 7.24 | 2 |
"""violation_ticket status change
Revision ID: 40adc38e9a22
Revises: a4c0c836847b
Create Date: 2025-09-29 13:56:25.386607
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '40adc38e9a22'
down_revision = 'a4c0c836847b'
bra... | bcgov/EPIC.compliance | compliance-api/migrations/versions/40adc38e9a22_violation_ticket_status_change.py | .py | 618463c890504ff3 | 7.24 | 2 |
"""add Other to initiation
Revision ID: 452a69254b48
Revises: 1637128b4b97
Create Date: 2025-07-03 15:24:02.193483
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '452a69254b48'
down_revision = '1637128b4b97'
branch_labels = None
depends_on = None
def upgrade... | bcgov/EPIC.compliance | compliance-api/migrations/versions/452a69254b48_add_other_to_initiation.py | .py | 42b8e1f47f293809 | 7.24 | 2 |
"""added source_title to requirement sources
Revision ID: 47b26a21801c
Revises: 452a69254b48
Create Date: 2025-07-07 11:45:51.046792
"""
from datetime import datetime
from pickle import TRUE
from alembic import op
from enum import Enum
import sqlalchemy as sa
from compliance_api.models.requirement_source import Requi... | bcgov/EPIC.compliance | compliance-api/migrations/versions/47b26a21801c_added_source_title_to_requirement_.py | .py | d00ddf263fb64437 | 7.24 | 2 |
"""complaint table creation
Revision ID: 4d8298d2ac7c
Revises: fd7af508a4fe
Create Date: 2024-09-12 10:39:59.575107
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4d8298d2ac7c'
down_revision = 'fd7af508a4fe'
branch_labels = None
depends_on = None
def upgrad... | bcgov/EPIC.compliance | compliance-api/migrations/versions/4d8298d2ac7c_complaint_table_creation.py | .py | 0dec67fc04d8ef14 | 7.24 | 2 |
"""ir_status_removed_debrief_date_added
Revision ID: 4dd4d28f1914
Revises: 6e1dd95e1a4d
Create Date: 2025-03-04 14:05:18.882604
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4dd4d28f1914'
down_revision = '6e1dd95e1a4d'
branch_labels = None
depends_on = None
... | bcgov/EPIC.compliance | compliance-api/migrations/versions/4dd4d28f1914_ir_status_removed_debrief_date_added.py | .py | aeca1eb3f6ce882c | 7.24 | 2 |
"""add natural sort function
Revision ID: 4f4bb8744a2a
Revises: 6edfa48316d0
Create Date: 2025-08-11 11:38:43.820784
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4f4bb8744a2a'
down_revision = '6edfa48316d0'
branch_labels = None
depends_on = None
def upgra... | bcgov/EPIC.compliance | compliance-api/migrations/versions/4f4bb8744a2a_add_natural_sort_function.py | .py | 04d3c97c3c8cec8e | 7.24 | 2 |
"""historical flag on enforcement action option
Revision ID: 5291fcced72e
Revises: dd08cb6df9ac
Create Date: 2025-07-23 11:05:02.242087
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5291fcced72e'
down_revision = 'dd08cb6df9ac'
branch_labels = None
depends_on... | bcgov/EPIC.compliance | compliance-api/migrations/versions/5291fcced72e_historical_flag_on_enforcement_action_.py | .py | c992b93ddcbed37e | 7.24 | 2 |
"""adding description to complaint source contact
Revision ID: 583a92eaa5f1
Revises: a37ed457f4cb
Create Date: 2024-09-25 13:14:27.200485
"""
from alembic import op
import sqlalchemy as sa
from compliance_api.models.type import EncryptedType
# revision identifiers, used by Alembic.
revision = "583a92eaa5f1"
down_re... | bcgov/EPIC.compliance | compliance-api/migrations/versions/583a92eaa5f1_adding_description_to_complaint_source_.py | .py | 9046860fc5827599 | 7.24 | 2 |
"""enforcement action option label change
Revision ID: 6b4b766bd2a3
Revises: 3af167e3a79f
Create Date: 2025-07-16 14:50:52.643683
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6b4b766bd2a3'
down_revision = '3af167e3a79f'
branch_labels = None
depends_on = Non... | bcgov/EPIC.compliance | compliance-api/migrations/versions/6b4b766bd2a3_enforcement_action_option_label_change.py | .py | 36f5f4b4e53122b6 | 7.24 | 2 |
"""Continuation report tables
Revision ID: 6d8d7b605eba
Revises: 21278058610c
Create Date: 2024-10-08 12:40:41.986778
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6d8d7b605eba'
down_revision = '21278058610c'
branch_labels = None
depends_on = None
def upgr... | bcgov/EPIC.compliance | compliance-api/migrations/versions/6d8d7b605eba_continuation_report_tables.py | .py | 6fd83e818b18be00 | 7.24 | 2 |
"""appendix-fkey-inspection added
Revision ID: 6e1dd95e1a4d
Revises: e8a29d9b9a0d
Create Date: 2025-02-26 11:43:42.768435
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6e1dd95e1a4d'
down_revision = 'e8a29d9b9a0d'
branch_labels = None
depends_on = None
def... | bcgov/EPIC.compliance | compliance-api/migrations/versions/6e1dd95e1a4d_appendix_fkey_inspection_added.py | .py | b5aad7a371beeb1c | 7.74 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.