repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
L0laapk3/RLBot-ReorientML
test.py
import random import sys from pathlib import Path from typing import Optional import math from rlbot.training.training import Grade from rlbot.utils.game_state_util import GameState, BallState, Physics, Rotator, Vector3, CarState from rlbottraining import exercise_runner from rlbottraining.match_configs import make_ma...
L0laapk3/RLBot-ReorientML
train_aerial_turn.py
<gh_stars>0 import sys, os from pathlib import Path import msvcrt import math import torch import gc from torch.optim.adadelta import Adadelta from quicktracer import trace from device import device delta_time = 1 / 120 steps = int(round(1.8 / delta_time)) hidden_size = 32 hidden_size_2 = 32 load = True rotation_eps ...
L0laapk3/RLBot-ReorientML
simulation_agent.py
<gh_stars>0 from rlbot.utils.game_state_util import GameState, Vector3, CarState, Physics, Rotator from rlbot.agents.base_agent import BaseAgent, SimpleControllerState from rlbot.utils.structures.game_data_struct import GameTickPacket from rlutilities.linear_algebra import euler_to_rotation, dot, transpose, look_at, v...
L0laapk3/RLBot-ReorientML
policy.py
<gh_stars>0 import torch from torch import Tensor from torch.nn import Module, Linear, ReLU import sys class Actor(Module): def __init__(self, hidden_size, hidden_size_2): super().__init__() self.linear1 = Linear(16, hidden_size) self.linear2 = Linear(hidden_size, hidden_size_2) sel...
L0laapk3/RLBot-ReorientML
device.py
<gh_stars>0 import torch import __main__ if __main__.__file__ == "train_aerial_turn.py": device = torch.device("cuda:0") else: device = torch.device("cpu")
L0laapk3/RLBot-ReorientML
torch_script.py
<reponame>L0laapk3/RLBot-ReorientML import torch from torch.onnx.utils import export import sys from pathlib import Path import numpy if __name__ == "__main__": current_path = Path(__file__).absolute().parent sys.path.insert(0, str(current_path.parent.parent)) # this is for first process imports from mec...
L0laapk3/RLBot-ReorientML
optimizer.py
import torch from torch.optim.optimizer import Optimizer class Yeet(Optimizer): """Implements Yeet algorithm by Hytak. Arguments: params (iterable): iterable of parameters to optimize or dicts defining parameter groups rho (float, optional): rho = 1 gives SGD, rho = 0 is a bit li...
L0laapk3/RLBot-ReorientML
base_mechanic.py
<gh_stars>0 from rlbot.agents.base_agent import SimpleControllerState class BaseMechanic: def __init__(self): self.controls = SimpleControllerState() self.finished = False def step(self, *args) -> SimpleControllerState: raise NotImplementedError
L0laapk3/RLBot-ReorientML
simulation.py
import torch from torch import Tensor from torch.distributions.normal import Normal import gc from policy import Policy from device import device # ?? j = 10.5 # air control torque coefficients t = torch.tensor([-400.0, -130.0, 95.0], dtype=torch.float, device=device) m = torch.diag(torch.ones(3)).bool().to(device) ...
johnjasa/ORBIT
tests/api/wisdem/test_fixed_wisdem_api.py
"""Tests for the Monopile Wisdem API""" __author__ = ["<NAME>"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import openmdao.api as om from ORBIT.api.wisdem import OrbitWisdemFixed def test_wisdem_monopile_api_default(): prob = om.Prob...
johnjasa/ORBIT
tests/phases/design/test_cable.py
<filename>tests/phases/design/test_cable.py """Provides a testing framework for the `Cable` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import copy import itertools import numpy as np import pytest from ORBIT...
johnjasa/ORBIT
tests/phases/install/turbine_install/test_turbine_install.py
<gh_stars>0 """Tests for the `MonopileInstallation` class without feeder barges.""" __author__ = "<NAME>" __copyright__ = "Copyright 2019, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy import pandas as pd import pytest from tests.data import test_we...
johnjasa/ORBIT
ORBIT/phases/install/mooring_install/mooring.py
<filename>ORBIT/phases/install/mooring_install/mooring.py """Installation strategies for mooring systems.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from marmot import process from ORBIT.core import Cargo, Vessel fr...
johnjasa/ORBIT
ORBIT/phases/design/__init__.py
<reponame>johnjasa/ORBIT """The design package contains `DesignPhase` and its subclasses.""" __author__ = ["<NAME>", "<NAME>"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = ["<NAME>", "<NAME>"] __email__ = ["<EMAIL>" "<EMAIL>"] from .design_phase import DesignPhase # isort:...
johnjasa/ORBIT
ORBIT/core/port.py
<filename>ORBIT/core/port.py """Provides the `Port` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import simpy from ORBIT.core.exceptions import ItemNotFound class Port(simpy.FilterStore): """Port Class"""...
johnjasa/ORBIT
tests/test_project_manager.py
<reponame>johnjasa/ORBIT __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy import pandas as pd import pytest from ORBIT import ProjectManager from tests.data import test_weather from ORBIT.library im...
johnjasa/ORBIT
tests/core/test_port.py
<gh_stars>10-100 """Tests for the `Port` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import pytest from marmot import Environment from ORBIT.core import Port, Cargo from ORBIT.core.exceptions import ItemNotFou...
johnjasa/ORBIT
ORBIT/core/components.py
<filename>ORBIT/core/components.py """Provides the `Crane` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import simpy from ORBIT.core._defaults import process_times as pt from ORBIT.core.exceptions import ( I...
johnjasa/ORBIT
ORBIT/core/_defaults.py
<reponame>johnjasa/ORBIT<gh_stars>0 """ <NAME> National Renewable Energy Lab 07/11/2019 This module contains default vessel process times. """ process_times = { # Export Cable Installation "onshore_construction_time": 48, # hr "trench_dig_speed": 0.1, # km/hr "pull_winch_speed": 5, # km/hr "to...
johnjasa/ORBIT
library/__init__.py
__author__ = ["<NAME>", "<NAME>"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = ["<EMAIL>", "<EMAIL>"] __status__ = "Development"
johnjasa/ORBIT
ORBIT/api/wisdem/fixed.py
"""WISDEM Monopile API""" __author__ = ["<NAME>"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import os import yaml import openmdao.api as om from ORBIT import ProjectManager class Orbit(om.Group): def setup(self): # D...
johnjasa/ORBIT
tests/test_design_install_phase_interactions.py
<reponame>johnjasa/ORBIT __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy from ORBIT import ProjectManager config = { "wtiv": "test_wtiv", "site": {"depth": 20, "distance": 20, "mean_windspe...
johnjasa/ORBIT
docs/conf.py
""" <NAME> National Renewable Energy Lab 09/13/2019 Configuration file for the Sphinx documentation builder. """ # -- Path setup -------------------------------------------------------------- import os import sys sys.path.insert(0, os.path.abspath("..")) import ORBIT # -- Project information --------------------...
johnjasa/ORBIT
tests/phases/install/test_install_phase.py
"""Tests for the `InstallPhase` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import pandas as pd import pytest from marmot import Environment from ORBIT.phases.install import InstallPhase class BadInstallPhas...
johnjasa/ORBIT
tests/phases/install/monopile_install/test_monopile_tasks.py
""" Testing framework for common monopile installation tasks. """ __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import pytest from ORBIT.core.exceptions import MissingComponent from ORBIT.phases.install.monopile_install.c...
johnjasa/ORBIT
ORBIT/phases/install/cable_install/common.py
"""Common processes and cargo types for Cable Installations.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from marmot import process from ORBIT.core.logic import position_onsite from ORBIT.core._defaults import proces...
johnjasa/ORBIT
tests/phases/design/test_project_development.py
"""Tests for the `ProjectDevelopment` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import os from copy import deepcopy import pytest from ORBIT.library import extract_library_specs from ORBIT.phases.design impo...
johnjasa/ORBIT
tests/phases/design/test_monopile_design.py
"""Tests for the `MonopileDesign` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy from itertools import product import pytest from ORBIT.phases.design import MonopileDesign base = { ...
johnjasa/ORBIT
ORBIT/phases/install/scour_protection_install/standard.py
"""`ScourProtectionInstallation` and related processes.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from math import ceil import simpy from marmot import process from ORBIT.core import Vessel from ORBIT.core._defaul...
johnjasa/ORBIT
tests/phases/install/mooring_install/test_mooring_install.py
""" Testing framework for the `MooringSystemInstallation` class. """ __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy import pandas as pd import pytest from tests.data import test_weather from ORBI...
johnjasa/ORBIT
tests/core/test_environment.py
<gh_stars>10-100 """Tests for the `Vessel` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import pandas as pd import pytest from marmot import le from ORBIT.core import Environment from tests.data import test_weat...
johnjasa/ORBIT
ORBIT/phases/install/__init__.py
"""The install package contains `InstallPhase` and its subclasses.""" __author__ = ["<NAME>", "<NAME>"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = ["<NAME>", "<NAME>"] __email__ = ["<EMAIL>" "<EMAIL>"] from .install_phase import InstallPhase # isort:skip from .oss_install...
johnjasa/ORBIT
tests/phases/design/test_export_system_design.py
<gh_stars>0 """Tests for the `ExportSystemDesign` class.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy import pytest from ORBIT.library import extract_library_specs from ORBIT.phases.design im...
johnjasa/ORBIT
ORBIT/phases/design/design_phase.py
"""Provides the base `DesignPhase` class.""" __author__ = ["<NAME>", "<NAME>"] __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from abc import abstractmethod from ORBIT.phases import BasePhase class DesignPhase(BasePhase): """BasePhase sub...
johnjasa/ORBIT
tests/conftest.py
"""Shared pytest settings and fixtures.""" import os import pytest from marmot import Environment from ORBIT.core import Vessel from tests.data import test_weather from ORBIT.library import initialize_library, extract_library_specs from ORBIT.phases.install.cable_install import SimpleCable def pytest_configure():...
johnjasa/ORBIT
ORBIT/phases/install/quayside_assembly_tow/__init__.py
"""Quayside assembly and tow-out modules.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from .moored import MooredSubInstallation from .gravity_base import GravityBasedInstallation
johnjasa/ORBIT
tests/phases/design/test_spar_design.py
<filename>tests/phases/design/test_spar_design.py __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" from copy import deepcopy from itertools import product import pytest from ORBIT.phases.design import SparDesign base = { ...
johnjasa/ORBIT
ORBIT/phases/install/oss_install/standard.py
"""`OffshoreSubstationInstallation` and related processes.""" __author__ = "<NAME>" __copyright__ = "Copyright 2020, National Renewable Energy Laboratory" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" import simpy from marmot import process from ORBIT.core import Vessel from ORBIT.core.logic import shuttle_items_...
dinarosv/fasttext-model
data/english_tweets/preprocess_tweets.py
<filename>data/english_tweets/preprocess_tweets.py import csv import re import string def remove_chars(text): # remove links pattern = re.compile(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') text = pattern.sub('', text) # remove tags text = re.sub(r'\w*@\w*', '...
dinarosv/fasttext-model
data/norec/norec_prep.py
from scripts import load, html_to_text import os import string import re def get_stop_words(): stop_words = [] with open("../stopwords/stopwords.txt") as infile: for line in infile: stop_words.append(line.split("\n")[0]) return stop_words def remove_stop_words(querytext, stop_words): ...
dinarosv/fasttext-model
testengmodel.py
<reponame>dinarosv/fasttext-model from fastText import load_model m = load_model("models/english_model.bin") with open("watson/examplesforwatson.txt") as test: for line in test: correct = line[9:10] predict = line[10:].replace("\n", "") prediciton = m.predict(predict, 1) value = pr...
dinarosv/fasttext-model
data/tn_mixed/shuffleset.py
<filename>data/tn_mixed/shuffleset.py import random with open('mixed.txt','r') as source: data = [ (random.random(), line) for line in source] data.sort() with open('mixed_shuffled.txt','w') as target: for _, line in data: target.write( line )
dinarosv/fasttext-model
data/twitter/fasttext_prep.py
<filename>data/twitter/fasttext_prep.py<gh_stars>0 import re # Prep does the same preprocessing as fastText in their examples def prep(text): text = text.lower() punctuations = [".", ",", "/", "'", "\"", "(", ")", "!", "?", ";", ":"] for p in punctuations: text = text.replace(p, " ") text = re....
dinarosv/fasttext-model
data/ft/preprocess.py
with open("two_labels.txt") as dataset: with open("twotrain.txt", "w") as train: with open("twotest.txt", "w") as test: for index, line in enumerate(dataset): if index > 0: text = "__label__" + line.split(";")[0] + " " + line.split(";")[1] + "\n" ...
dinarosv/fasttext-model
data/norec/fasttext_prep.py
with open("dataset.txt") as dataset: with open("train.txt", "w") as train: with open("test.txt", "w") as test: for index, line in enumerate(dataset): text = "__label__" + line[0] + line[1:] if index < (35189*0.8): train.write(text) ...
dinarosv/fasttext-model
data/norec/scripts/misc.py
<filename>data/norec/scripts/misc.py # Copyright 2017 <NAME> <<EMAIL>> # This file is part of norec. # norec is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your opti...
dinarosv/fasttext-model
data/tn_mixed/fasttext_prep.py
<filename>data/tn_mixed/fasttext_prep.py<gh_stars>0 with open('not_stemmed.txt') as readfile: with open('train.txt', 'w') as trainfile: with open('test.txt', 'w') as testfile: for index, line in enumerate(readfile): txt = "__label__" + line.split(";")[0] + " " + line.split(";")[1...
dinarosv/fasttext-model
data/imdb/fasttext_prep.py
import re import string def remove_chars(text): # remove links pattern = re.compile(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') text = pattern.sub('', text) # remove punctuations text = text.translate(str.maketrans('', '', string.punctuation)) # remove new...
dinarosv/fasttext-model
data/twitter/countlabels.py
pos = 0 neu = 0 neg = 0 with open("dataset.txt") as f: for line in f: if line[0] == "0": neg += 1 elif line[0] == "1": neu += 1 elif line[0] == "2": pos += 1 print(pos) print(neu) print(neg)
dinarosv/fasttext-model
data/english_tweets/fasttext_prep.py
# Split twitter dataset in training and testing with ratio 80/20 with open("snewdataset.txt") as infile: with open("train.txt", "w") as train: with open("test.txt", "w") as test: for index, line in enumerate(infile): if index != 0: if index < round(4724 * 0.8)...
dinarosv/fasttext-model
data/norec/scripts/conllu.py
<gh_stars>0 # Copyright 2017 <NAME> <<EMAIL>> # This file is part of norec. # norec is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. #...
dinarosv/fasttext-model
data/norec/scripts/__init__.py
<reponame>dinarosv/fasttext-model from .main import load, html_to_text, conllu_to_tokens, load_metadata
dinarosv/fasttext-model
data/norec/scripts/main.py
# Copyright 2017 <NAME> <<EMAIL>> # This file is part of norec. # norec is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # norec is di...
dinarosv/fasttext-model
watson/watsontranslate.py
import json from watson_developer_cloud import NaturalLanguageUnderstandingV1, LanguageTranslatorV3 from apikeys import apikeytrans if __name__ == "__main__": translator = LanguageTranslatorV3( version='2018-05-01', iam_apikey=apikeytrans, url='https://gateway-lon.watsonplatform.net/language-translator...
dinarosv/fasttext-model
watson/watsonvalidate.py
<reponame>dinarosv/fasttext-model import json import os from watson_developer_cloud import NaturalLanguageUnderstandingV1, LanguageTranslatorV3 from watson_developer_cloud.natural_language_understanding_v1 import Features, SentimentOptions from apikeys import apikeyvalid import time if __name__ == "__main__": nlu ...
dinarosv/fasttext-model
watson/watsontesting.py
if __name__ == "__main__": corrects = 0 total = 0 with open("../data/amazon/result_wat.txt") as watsonfile, open("../data/amazon/cuttest.ft.txt") as validationfile: for x, y in zip(watsonfile, validationfile): line = x.strip() corrline = y.strip() if line[9:10] =...
dinarosv/fasttext-model
trainmodel.py
<reponame>dinarosv/fasttext-model from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import fastText from fastText import train_supervised import os import time import sys # Arguments: Trainfile, testfile, model, bestpa...
dinarosv/fasttext-model
data/norec/countlabels.py
with open("dataset.txt") as readfile: neu = 0 pos = 0 neg = 0 for line in readfile: if line[0] == "0": neg += 1 elif line[0] == "1": neu += 1 elif line[0] == "2": pos += 1 print(neg) print(neu) print(pos)
dinarosv/fasttext-model
testmodel.py
<reponame>dinarosv/fasttext-model from fastText import load_model import sys import os from trainmodel import print_results import time def stripName(text): return text[0][0].split('__')[2] def strip_prob(text): return text[1][0] def count_labels(): pos = 0 neg = 0 neu = 0 trainfile = sys.arg...
sotte/great_expectations
tests/test_pandas_dataset.py
from __future__ import division import unittest import json import datetime import pandas as pd import great_expectations as ge from .test_utils import assertDeepAlmostEqual class TestPandasDataset(unittest.TestCase): def run_encapsulated_test(self, expectation_name, filename): with open(filename) as f...
sotte/great_expectations
great_expectations/data_context/__init__.py
from .pandas_context import PandasCSVDataContext from .sqlalchemy_context import SqlAlchemyDataContext def get_data_context(context_type, options): """Return a data_context object which exposes options to list datasets and get a dataset from that context. This is a new API in Great Expectations 0.4, and is sub...
sotte/great_expectations
tests/test_data_contexts/test_data_contexts.py
import pytest import os import sqlalchemy as sa import pandas as pd from great_expectations import get_data_context from great_expectations.dataset import PandasDataset, SqlAlchemyDataset @pytest.fixture(scope="module") def test_db_connection_string(tmpdir_factory): df1 = pd.DataFrame({'col_1': [1, 2, 3, 4, 5],...
sotte/great_expectations
great_expectations/dataset/base.py
<gh_stars>0 from __future__ import division import json import inspect import copy from functools import wraps import traceback import warnings from six import string_types from collections import namedtuple from collections import ( Counter, defaultdict ) from ..version import __version__ from .util import D...
sotte/great_expectations
tests/test_utils.py
from __future__ import division import pandas as pd import numpy as np from sqlalchemy import create_engine from great_expectations.dataset import PandasDataset, SqlAlchemyDataset ## Taken from the following stackoverflow: https://stackoverflow.com/questions/23549419/assert-that-two-dictionaries-are-almost-equal de...
ash2shukla/mongodb-timepass
src/pages/update.py
from json.decoder import JSONDecodeError import streamlit as st from ..utils import Page import streamlit as st from ..db import MongoDBClient import json class UpdatePage(Page): RENAME_COLL_OPT = "Update Collection Name" UPDATE_DOCS_OPT = "Update Documents" def __init__(self, state): ...
ash2shukla/mongodb-timepass
src/db.py
<gh_stars>0 import streamlit as st import pymongo from bson import json_util import json from functools import lru_cache class MongoDBClient: def __init__(self, CONN_URI): self.conn = pymongo.MongoClient(CONN_URI) def get_database_names(self): return self.conn.list_database_name...
ash2shukla/mongodb-timepass
src/pages/explore.py
<filename>src/pages/explore.py<gh_stars>0 import streamlit as st from ..utils import Page import streamlit as st from math import ceil from json import loads, JSONDecodeError import json class ExplorePage(Page): def __init__(self, state): self.state = state self.db_client = self.state.d...
ash2shukla/mongodb-timepass
src/pages/delete.py
from json.decoder import JSONDecodeError import streamlit as st from ..utils import Page import streamlit as st from ..db import MongoDBClient import json class DeletePage(Page): DROP_DB_OPT = "Drop database" DROP_COLL_OPT = "Drop collection" DELETE_DOC_OPT = "Remove document(s)" def __i...
ash2shukla/mongodb-timepass
src/pages/create.py
from json.decoder import JSONDecodeError import streamlit as st from ..utils import Page import streamlit as st from ..db import MongoDBClient import json class CreatePage(Page): CREATE_NEW_DB_OPT = "CREATE NEW DATABASE" CREATE_NEW_COLL_OPT = "CREATE NEW COLLECTION" COLL_OPT = "collection" ...
ash2shukla/mongodb-timepass
main.py
<gh_stars>0 import streamlit as st from src.utils import Page, provide_state, get_base_64_img, _skip_hash from src.pages import ExplorePage, CreatePage, UpdatePage, DeletePage from pathlib import Path from src.db import MongoDBClient import pymongo from typing import Dict, Type PAGE_MAP: Dict[str, Type[P...
ash2shukla/mongodb-timepass
src/pages/__init__.py
from .explore import ExplorePage from .create import CreatePage from .update import UpdatePage from .delete import DeletePage __all__ = ["ExplorePage", "CreatePage", "UpdatePage", "DeletePage"]
adriengentil/assisted-test-infra
src/update_assisted_service_cm.py
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Idea is to pass os environments to assisted-service config map, to make an easy way to configure assisted-service Note: defaulting an env var to "" in Makefile, will result in an empty string value in the configmap. E.g. Makefile: MY_VAR := $(or $(MY_VAR), "") configmap...
adriengentil/assisted-test-infra
src/triggers/olm_operators_trigger.py
<gh_stars>0 from contextlib import suppress from typing import Callable from assisted_test_infra.test_infra.utils.operators_utils import resource_param from consts import OperatorResource from triggers.env_trigger import Trigger, Triggerable class OlmOperatorsTrigger(Trigger): def __init__(self, condition: Calla...
adriengentil/assisted-test-infra
src/assisted_test_infra/test_infra/controllers/ipxe_controller/ipxe_controller.py
import os import shutil import consts from assisted_test_infra.test_infra import utils from service_client import InventoryClient, log class IPXEController: def __init__( self, api_client: InventoryClient, name: str = None, port: int = consts.DEFAULT_IPXE_SERVER_PORT, ip: ...
adriengentil/assisted-test-infra
src/assisted_test_infra/test_infra/utils/operators_utils.py
import os from typing import List import waiting from assisted_service_client import MonitoredOperator import consts from service_client import InventoryClient, log def get_env(env, default=None): res = os.environ.get(env, "").strip() if not res or res == '""': res = default return res def par...
adriengentil/assisted-test-infra
src/triggers/env_trigger.py
import inspect import re from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List from assisted_test_infra.test_infra.utils import EnvVar from service_client import log class DataPool(ABC): @classmethod @abstractmethod def get_env(cls, item) -> EnvVar: pass class Trigger...
adriengentil/assisted-test-infra
src/assisted_test_infra/test_infra/helper_classes/infra_env.py
<reponame>adriengentil/assisted-test-infra<filename>src/assisted_test_infra/test_infra/helper_classes/infra_env.py import json import os from pathlib import Path from typing import List, Optional from assisted_service_client import models from junit_report import JunitTestCase import consts from assisted_test_infra.t...
adriengentil/assisted-test-infra
src/assisted_test_infra/test_infra/controllers/ipxe_controller/server/local_ipxe_server.py
<filename>src/assisted_test_infra/test_infra/controllers/ipxe_controller/server/local_ipxe_server.py<gh_stars>0 #!/usr/bin/python3 import os from http.server import CGIHTTPRequestHandler, HTTPServer ip = os.getenv("SERVER_IP", "192.168.122.1") port = int(os.getenv("SERVER_PORT", 8500)) # Make sure the server is host...
adriengentil/assisted-test-infra
src/assisted_test_infra/test_infra/helper_classes/config/nodes_config.py
<reponame>adriengentil/assisted-test-infra from abc import ABC from dataclasses import dataclass, field from typing import Dict, List from munch import Munch from .controller_config import BaseNodeConfig @dataclass class BaseTerraformConfig(BaseNodeConfig, ABC): """ Define all configurations variables that ...
adriengentil/assisted-test-infra
scripts/override_release_images.py
<reponame>adriengentil/assisted-test-infra #!/usr/bin/python3 # -*- coding: utf-8 -*- import json import os import shlex import subprocess import tempfile from argparse import ArgumentParser from contextlib import contextmanager import semver @contextmanager def pull_secret_file(): pull_secret = os.environ.get("...
adriengentil/assisted-test-infra
src/assisted_test_infra/test_infra/helper_classes/config/controller_config.py
import warnings from abc import ABC from dataclasses import dataclass from pathlib import Path from typing import List import consts from .base_config import BaseConfig @dataclass class BaseNodeConfig(BaseConfig, ABC): platform: str = None is_ipv4: bool = None is_ipv6: bool = None bootstrap_in_place...
nshaikh1/DesignAndMaintenance
design-patterns/flyweight-python/flyweight.py
import json from typing import Dict class Flyweight(): """ Intrinsic State: The Flyweight stores a common portion of the state (also called intrinsic state) that belongs to multiple real business entities. The Flyweight accepts the rest of the state (extrinsic state, unique for each entity) via ...
nshaikh1/DesignAndMaintenance
design-patterns/adapter-python/Adapter.py
class OnePlus: """Class for OnePlus""" def __init__(self): self.name = "OnePlus" def O(self): return "2400" class Apple: """Class for Apple""" def __init__(self): self.name = "Apple" def A(self): return "1750" class Samsung: """Class for Samsung""" def __init__(self): self.name = ...
nshaikh1/DesignAndMaintenance
design-patterns/proxy-python/proxy.py
<reponame>nshaikh1/DesignAndMaintenance """Interface for Proxy and real project.""" class Shape_Interface: def triangle(self, height, base): raise NotImplementedError() def parallelo_gram(self, height, base): raise NotImplementedError() def rectangle(self, height, base): raise No...
nshaikh1/DesignAndMaintenance
design-patterns/builder-python/builder.py
<reponame>nshaikh1/DesignAndMaintenance # Director: returns assembled plane class Director(object): plane_builder = None def setBuilder(self, builder): self.plane_builder = builder # code for assembling a plane def getPlane(self): plane = Plane() ...
nshaikh1/DesignAndMaintenance
design-patterns/factory-method-python/factory.py
<reponame>nshaikh1/DesignAndMaintenance<gh_stars>1-10 # Python Code for factory method # it comes under the creational # Design Pattern class HexadecimalLocalizer: """ it simply returns the hexadecimal version """ def localize(self, value): data = {0 : "0", 1 : "1", 2 : "2...
nshaikh1/DesignAndMaintenance
design-patterns/decorator-python/decorator.py
<reponame>nshaikh1/DesignAndMaintenance class distance_units: def __init__(self, length): self._length = length def convert(self): return self._length class decorator(distance_units): def __init__(self, length): self._length = length def convert(self): return self...
nshaikh1/DesignAndMaintenance
design-patterns/singleton-python/singleton.py
def singleton(myClass): instances = {} #dictonary of instances def getInstance(*args, **kwargs): if myClass not in instances: #if instance of myClass is not already there in dictonary of instances instances[myClass] = myClass(*args, **kwargs) #Create new instance return instances[myClass] #return newly created...
nshaikh1/DesignAndMaintenance
design-patterns/bridge-python/bridge.py
<filename>design-patterns/bridge-python/bridge.py from __future__ import annotations from abc import ABC, abstractmethod class Ford_Mustang: """ The abstraction Ford_Mustang defines the interface for the "control" part of the two class hierarchies. It maintains a reference to an object of the implemen...
nshaikh1/DesignAndMaintenance
design-patterns/composite-python/Composite.py
class CompositeInterface: def showDetails(self): pass class LeafElement(CompositeInterface): '''Class representing objects at the bottom.''' def __init__(self, *args): ''''Takes the first positional argument and assigns to member variable "position".''' self.position = args[0] def showDeta...
nshaikh1/DesignAndMaintenance
design-patterns/prototype-python/prototype.py
#shallow copy : copy.copy() #Shallow copy creates a copy of that object but references each element of that object. #deep copy : copy.deepcopy() #The objects that support cloning are called prototypes. from copy import deepcopy class body_Temp(object): def __init__(self, centigrade, Fahrenheit): ...
nshaikh1/DesignAndMaintenance
design-patterns/abstract-factory-python/abstract_factory_method.py
# Python Code for object # oriented concepts using # the abstract factory # design patter import random class Cars_avaliable: def __init__(self, Car = None): self.cars = Car def show_car(self): rental = self.cars() print(f'Name of car {rental}') ...
lereldarion/slam
slam/plugins/backlight.py
# Copyright (c) 2013-2015 <NAME> # # 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, including # without limitation the rights to use, copy, modify, merge, publish, # dist...
lereldarion/slam
slam/__init__.py
<filename>slam/__init__.py # Copyright (c) 2013-2017 <NAME> # # 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, including # without limitation the rights to use, copy, mod...
lereldarion/slam
setup.py
# Copyright (c) 2013-2015 <NAME> # # 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, including # without limitation the rights to use, copy, modify, merge, publish, # dist...
lereldarion/slam
slam/xcb_backend.py
# Copyright (c) 2013-2017 <NAME> # # 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, including # without limitation the rights to use, copy, modify, merge, publish, # dist...
lereldarion/slam
slam/layout.py
# Copyright (c) 2013-2017 <NAME> # # 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, including # without limitation the rights to use, copy, modify, merge, publish, # dist...
lereldarion/slam
slam/util.py
# Copyright (c) 2013-2017 <NAME> # # 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, including # without limitation the rights to use, copy, modify, merge, publish, # dist...
editorconfig/editorconfig-sublime
editorconfig/__init__.py
"""EditorConfig Python Core""" from editorconfig.versiontools import join_version VERSION = (0, 11, 1, "final") __all__ = ['get_properties', 'EditorConfigError', 'exceptions'] __version__ = join_version(VERSION) def get_properties(filename): """Locate and parse EditorConfig files for the given filename""" ...
editorconfig/editorconfig-sublime
EditorConfig.py
<filename>EditorConfig.py import sublime_plugin from editorconfig import get_properties, EditorConfigError LINE_ENDINGS = { 'lf': 'unix', 'crlf': 'windows', 'cr': 'cr' } CHARSETS = { 'latin1': 'Western (ISO 8859-1)', 'utf-8': 'utf-8', 'utf-8-bom': 'utf-8 with bom', 'utf-16be': 'utf-16 be', 'utf-16le': 'utf-1...