Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: Refactor the Readme fille #4

Open
2 tasks done
onuratakan opened this issue Mar 9, 2024 · 1 comment · May be fixed by #6
Open
2 tasks done

Sweep: Refactor the Readme fille #4

onuratakan opened this issue Mar 9, 2024 · 1 comment · May be fixed by #6
Labels

Comments

@onuratakan
Copy link
Member

onuratakan commented Mar 9, 2024

Checklist
  • Modify README.mdf7ecd05 Edit
  • Running GitHub Actions for README.mdEdit
@onuratakan
Copy link
Member Author

onuratakan commented Mar 9, 2024

🚀 Here's the PR! #6

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: None)
Install Sweep Configs: Pull Request

Tip

I can email you next time I complete a pull request if you set up your email here!


Actions (click)

  • ↻ Restart Sweep

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description.

Upsonic/setup.py

Lines 1 to 24 in 5e10999

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from setuptools import setup
with open('requirements.txt') as fp:
install_requires = fp.read()
setup(
name="upsonic",
version="0.14.1",
description="""Magic Cloud Layer""",
long_description="".join(open("README.md", encoding="utf-8").readlines()),
long_description_content_type="text/markdown",
url="https://github.com/Upsonic/Upsonic",
author="Upsonic",
author_email="onur.atakan.ulusoy@upsonic.co",
license="MIT",
packages=["upsonic", "upsonic.remote"],
install_requires=install_requires,
entry_points={
"console_scripts": ["upsonic=upsonic.remote.interface:Upsonic_CLI"],
},
python_requires=">= 3",
zip_safe=False,

class Upsonic_Remote:
prevent_enable = False
quiet_startup = False
def _log(self, message):
if not self.quiet:
self.console.log(message)
def __enter__(self):
return self # pragma: no cover
def __exit__(self, exc_type, exc_val, exc_tb):
pass # pragma: no cover
def __init__(self, database_name, api_url, password=None, enable_hashing:bool=False, verify=True, locking=False, client_id=None, cache=False, cache_counter=None, version=False, client_version=False, key_encyption=False, meta_datas = True, quiet=False, thread_number=1):
import requests
from requests.auth import HTTPBasicAuth
self.thread_number = thread_number
self.quiet = quiet
self.meta_datas = meta_datas
self.force_compress = False
self.force_encrypt = False
self.key_encyption = key_encyption
self.locking = locking
self.enable_hashing = enable_hashing
self.cache = cache
self.cache_counter = cache_counter
self._cache_counter = {}
self.local_cache = {}
self.cache_dir = os.path.join(os.getcwd(), "upsonic_cache")
if not os.path.exists(self.cache_dir):
os.mkdir(self.cache_dir)
self.client_id = client_id
self.verify = verify
from upsonic import console
self.console = console
self.requests = requests
self.HTTPBasicAuth = HTTPBasicAuth
self.database_name = database_name
if not Upsonic_Remote.quiet_startup:
self._log(
f"[{self.database_name[:5]}*] [bold white]Upsonic Cloud[bold white] initializing...",
)
if self.client_id is not None:
if not Upsonic_Remote.quiet_startup:
self._log(f"[{self.database_name[:5]}*] [bold white]Client ID[bold white]: {self.client_id}")
from upsonic import encrypt, decrypt
self.encrypt = encrypt
self.decrypt = decrypt
self.api_url = api_url
self.password = password
try:
self.informations = self._informations()
except TypeError:
self.informations = None
if self.informations is not None:
rate_limits = self.informations["rate_limit"][1]
rate_limits = rate_limits.split(" ")
self.rate_limit = int(rate_limits[1])
self.thread_number = 10
if not Upsonic_Remote.quiet_startup:
self._log(
f"[{self.database_name[:5]}*] [bold green]Upsonic Cloud[bold green] active",
)
self._log("---------------------------------------------")
if self.cache:
self.cache_hash_load()
if self._cache_hash is None:
self._cache_hash = {}
self.cache_hash_save()
self.version = version
self.client_version = client_version
self.enable_active = False
def install_package(self, package):
from pip._internal import main as pip
package_name = package.split("==")[0]
package_version = package.split("==")[1] if len(package.split("==")) > 1 else "Latest"
the_dir = os.path.abspath(os.path.join(self.cache_dir, package_name, package_version))
if not os.path.exists(the_dir):
os.makedirs(the_dir)
pip(["install", package, "--target", the_dir])
@contextmanager
def import_package(self, package):
"""
import sys
for a in list(sys.modules):
if a.startswith("numpy"):
del sys.modules[a]
"""
package_name = package.split("==")[0]
package_version = package.split("==")[1] if len(package.split("==")) > 1 else "Latest"
the_dir = os.path.abspath(os.path.join(self.cache_dir, package_name, package_version))
if not os.path.exists(the_dir):
self.install_package(package)
sys_path_backup = sys.path.copy()
sys.path.insert(0, the_dir)
try:
yield
finally:
sys.path = sys_path_backup
def extend_global(self, name, value):
globals()[name] = value
def load_module(self, module_name, encryption_key="a"):
the_all = self.get_all(encryption_key=encryption_key)
the_all_imports = {}
for i, value in the_all.items():
if "_upsonic_" in i:
continue
name = i.split(".")
if module_name == name[0]:
the_all_imports[i] = value
import types
def create_module_obj(dictionary):
result = {}
for key, value in dictionary.items():
modules = key.split('.')
current_dict = result
for module in modules[:-1]:
if module not in current_dict:
current_dict[module] = types.ModuleType(module)
current_dict = vars(current_dict[module])
current_dict[modules[-1]] = value
return result
generated_library = create_module_obj(the_all_imports)[module_name]
return generated_library
def enable(self, encryption_key="a", the_globals={}):
the_keys = {}
if Upsonic_Remote.prevent_enable:
return the_keys.items()
from upsonic import interface
for key, value in the_globals.items():
setattr(interface, key, value)
globals()[key] = value
self._log("[bold white]Syncing with Upsonic Cloud...")
self.enable_active = True
the_all_imports = {}
the_us = self
#Register the_us to globals
globals()["the_us"] = the_us
the_all = self.get_all(encryption_key=encryption_key)
for key, value in the_all.items():
if "_upsonic_" not in key:
try:
original_key = key
original_key_without_dow = key.replace(".", "_")
key = key.split(".")
message = value
from upsonic import interface
setattr(interface, key[-1], copy.copy(message))
the_keys[key[-1]] = copy.copy(message)
except:
import traceback
traceback.print_exc()
self._log(f"[bold white]Error on patching '{key}'")
return the_keys.items()
def dump_module(self, module_name, module, encryption_key="a", compress=None, liberty=True):
top_module = module
cloudpickle.register_pickle_by_value(top_module)
sub_modules = []
if hasattr(top_module, "__path__"):
for importer, modname, ispkg in pkgutil.walk_packages(path=top_module.__path__,
prefix=top_module.__name__+'.',
onerror=lambda x: None):
sub_modules.append(importer.find_module(modname).load_module(modname))
else:
sub_modules.append(top_module)
threads = []
the_list= []
for sub_module in sub_modules:
[the_list.append(obj) for name, obj in inspect.getmembers(sub_module)]
# Extract just functions and classes
the_list = [i for i in the_list if inspect.isfunction(i) or inspect.isclass(i)]
# If the __module__ is not equal to module_name, remove it from the list
the_list = [i for i in the_list if i.__module__.split(".")[0] == module_name]
my_list = []
for element in copy.copy(the_list):
if inspect.isfunction(element):
name = element.__module__ +"." + element.__name__
elif inspect.isclass(element):
name = element.__module__ +"." + element.__name__
if not "upsonic.remote" in name and not "upsonic_updater" in name and name != f"{module.__name__}.threading.Thread":
my_list.append(element)
the_list = my_list
with Progress() as progress:
task1 = progress.add_task(" [red]Job Started...", total=len(the_list))
task2 = progress.add_task(" [green]Job Complated...", total=len(the_list))
for element in the_list:
time.sleep(0.1)
if inspect.isfunction(element):
name = element.__module__ +"." + element.__name__
elif inspect.isclass(element):
name = element.__module__ +"." + element.__name__
else:
continue
first_element = name.split(".")[0]
if first_element != module_name:
continue
try:
while len(threads) >= self.thread_number:
for each in threads:
if not each.is_alive():
threads.remove(each)
time.sleep(0.1)
the_thread = threading.Thread(target=self.set, args=(name, element), kwargs={"encryption_key": encryption_key, "compress": compress, "liberty": liberty})
the_thread.start()
thread = the_thread
threads.append(thread)
progress.update(task1, advance=1)
except:
import traceback
traceback.print_exc()
self._log(f"[bold red]Error on '{name}'")
self.delete(name)
for each in threads:
progress.update(task2, advance=1)
each.join()
def get_set_version_tag(self, client_id=None):
the_key = "set_version_number"
if client_id is not None:
the_key = the_key + f"_{client_id}"
else:
if self.client_version:
the_key = the_key + f"_{self.client_id}"
the_version = self.get(the_key, no_version=True)
if the_version is None:
return None
if the_version == "latest":
return None
return the_version
def get_get_version_tag(self, client_id=None):
the_key = "get_version_number"
if client_id is not None:
the_key = the_key + f"_{client_id}"
else:
if self.client_version:
the_key = the_key + f"_{self.client_id}"
the_version = self.get(the_key, no_version=True)
if the_version is None:
return None
if the_version == "latest":
return None
return the_version
def set_set_version(self, version_tag, client_id=None):
the_key = "set_version_number"
if client_id is not None:
the_key = the_key + f"_{client_id}"
else:
if self.client_version:
the_key = the_key + f"_{self.client_id}"
return self.set(the_key, version_tag, no_version=True)
def set_get_version(self, version_tag, client_id=None):
the_key = "get_version_number"
if client_id is not None:
the_key = the_key + f"_{client_id}"
else:
if self.client_version:
the_key = the_key + f"_{self.client_id}"
return self.set(the_key, version_tag, no_version=True)

def cache_hash_save(self):
# Save the cache_hash to workdir/upsonic_cache_hash
with open(os.path.join(self.cache_dir, "upsonic_cache_hash"), "wb") as f:
pickle.dump(self._cache_hash, f)
def cache_hash_load(self):
# Load the cache_hash from workdir/upsonic_cache_hash
try:
with open(os.path.join(self.cache_dir, "upsonic_cache_hash"), "rb") as f:
self._cache_hash = pickle.load(f)
except FileNotFoundError:
self._cache_hash = None
def cache_set(self, key, value):
self.local_cache[key] = value
with open(f"{self.cache_dir}/{sha256(key.encode()).hexdigest()}", "wb") as f:
pickle.dump(value, f)
def cache_get(self, key):
if key in self.local_cache:
return self.local_cache[key]
with open(f"{self.cache_dir}/{sha256(key.encode()).hexdigest()}", "rb") as f:
return pickle.load(f)
def cache_pop(self, key):
if key in self.local_cache:
self.local_cache.pop(key)
try:
os.remove(f"{self.cache_dir}/{sha256(key.encode()).hexdigest()}")
except:
pass
def _informations(self):
return self._send_request("GET", "/informations", make_json=True)
def debug(self, message):
data = {"message": message}
return self._send_request("POST", "/controller/debug", data)
def info(self, message):
data = {"message": message}
return self._send_request("POST", "/controller/info", data)
def warning(self, message):
data = {"message": message}
return self._send_request("POST", "/controller/warning", data)
def error(self, message):
data = {"message": message}
return self._send_request("POST", "/controller/error", data)
def exception(self, message):
data = {"message": message}
return self._send_request("POST", "/controller/exception", data)
def _send_request(self, method, endpoint, data=None, make_json=False):
try:
response = self.requests.request(
method,
self.api_url + endpoint,
data=data,
auth=self.HTTPBasicAuth("", self.password),
verify=self.verify
)
try:
response.raise_for_status()
return response.text if not make_json else json.loads(response.text)
except self.requests.exceptions.RequestException as e: # pragma: no cover
print(f"Error on '{self.api_url + endpoint}': ", response.text)
return None # pragma: no cover
except self.requests.exceptions.ConnectionError:
print("Error: Remote is down")
return None
def _lock_control(self, key, locking_operation=False):
the_client_id = self.client_id
if the_client_id is None:
the_client_id = "Unknown"
result = self.get(key+"_upsonic_lock", encryption_key=None, no_cache=True)
if result is not None:
result = result[1:]
result = result[:-2]
if result == the_client_id and not locking_operation:
return False
return True
return False
def lock_control(self, key):
if self.locking:
return self._lock_control(key)
else:
return False
def lock_key(self, key):
if self._lock_control(key, locking_operation=True):
self._log(f"[bold red] '{key}' is already locked")
return False
the_client_id = self.client_id
if the_client_id is None:
the_client_id = "Unknown"
if self.set(key+"_upsonic_lock", the_client_id, locking_operation=True, encryption_key=None, no_cache=True) == "Data set successfully":
self._log(f"[bold green] '{key}' is locked")
return True
else:
return False
def unlock_key(self, key):
result = self._lock_control(key, locking_operation=True)
if not result:
self._log(f"[bold red] '{key}' is already unlocked")
return False
if self._lock_control(key):
self._log(f"[bold red] '{key}' is locked by another client")
return False
if self.delete(key+"_upsonic_lock") == "Data deleted successfully":
self._log(f"[bold green] '{key}' is unlocked")
return True
else:
return False
def _update_set(self, key, meta):
if self.meta_datas:
return self.set(key+"_upsonic_meta", meta, update_operation=True, encryption_key=None)
def _liberty_set(self, key, liberty_class):
if liberty_class:
self.set(key+"_upsonic_liberty_class", True, update_operation=True, encryption_key=None)
else:
self.delete(key+"_upsonic_liberty_class")
return self.set(key+"_upsonic_liberty", True, update_operation=True, encryption_key=None)
def _liberty_unset(self, key, liberty_class):
if liberty_class:
self.delete(key+"_upsonic_liberty_class")
self.delete(key+"_upsonic_liberty")
def dump(self, key, value, encryption_key="a", compress=None, cache_policy=0, locking_operation=False, update_operation=False, version_tag=None, no_version=False, liberty=True):
return self.set(key, value, encryption_key=encryption_key, compress=compress, cache_policy=cache_policy, locking_operation=locking_operation, update_operation=update_operation, version_tag=version_tag, no_version=no_version, liberty=liberty)
def load(self, key, encryption_key="a", no_cache=False, version_tag=None, no_version=False):
return self.get(key, encryption_key=encryption_key, no_cache=no_cache, version_tag=version_tag, no_version=no_version)
def set(self, key, value, encryption_key="a", compress=None, cache_policy=0, locking_operation=False, update_operation=False, version_tag=None, no_version=False, liberty=True):
self.cache_pop(key)
if not locking_operation:
if self.lock_control(key):
self._log(f"[bold red] '{key}' is locked")
return None
the_type = type(value).__name__
if the_type == "type":
the_type = "class"
meta = {'type_of_value': the_type}
meta = json.dumps(meta)
compress = True if self.force_compress else compress
encryption_key = (
self.force_encrypt if self.force_encrypt != False else encryption_key
)
liberty_class = inspect.isclass(value)
if encryption_key is not None:
value = self.encrypt(encryption_key, value, liberty=liberty)
if not "_upsonic_" in key:
if liberty:
self._liberty_set(key, liberty_class)
else:
self._liberty_unset(key, liberty_class)
key = sha256(key.encode()).hexdigest() if self.key_encyption else key
data = {
"database_name": self.database_name,
"key": key,
"value": value,
"compress": compress,
"cache_policy": cache_policy,
}
if version_tag is not None:
copy_data = copy.copy(data)
copy_data["key"] = copy_data["key"] + f"_upsonic_version_{version_tag}"
self._send_request("POST", "/controller/set", copy_data)
if not update_operation:
self._update_set(copy_data["key"], meta)
elif self.version and not no_version:
the_version_ = self.get_set_version_tag()
if the_version_ is not None:
copy_data = copy.copy(data)
copy_data["key"] = copy_data["key"] + f"_upsonic_version_{the_version_}"
self._send_request("POST", "/controller/set", copy_data)
if not update_operation:
self._update_set(copy_data["key"], meta)
if not update_operation:
self._update_set(key, meta)
return self._send_request("POST", "/controller/set", data)
def get(self, key, encryption_key="a", no_cache=False, version_tag=None, no_version=False):
key = sha256(key.encode()).hexdigest() if self.key_encyption else key
if version_tag is not None:
key = key + f"_upsonic_version_{version_tag}"
elif self.version and not no_version:
the_version_ = self.get_get_version_tag()
if the_version_ is not None:
key = key + f"_upsonic_version_{the_version_}"
response = None
if self.cache and not no_cache:
if key not in self._cache_counter:
self._cache_counter[key] = 0
self._cache_counter[key] = self._cache_counter[key] + 1
if self._cache_counter[key] < self.cache_counter and self._cache_counter[key] != 1:
try:
response = self.cache_get(key)
except FileNotFoundError:
pass
else:
if self._cache_counter[key] >= self.cache_counter:
self._cache_counter[key] = 1
the_hash = self.get(key+"_upsonic_updated", no_cache=True, no_version=True)
if key not in self._cache_hash:
self._cache_hash[key] = None
if the_hash != self._cache_hash[key] and the_hash is not None:
self._cache_hash[key] = the_hash
self.cache_hash_save()
self._log("Cache is updated")
try:
self.cache_pop(key)
except FileNotFoundError:
pass
else:
try:
response = self.cache_get(key)
except FileNotFoundError:
pass
encryption_key = (
self.force_encrypt if self.force_encrypt != False else encryption_key
)
data = {"database_name": self.database_name, "key": key}
if response is None:
response = self._send_request("POST", "/controller/get", data)
if self.cache:
self.cache_set(key, response)
if response is not None:
if not response == "null\n":
# Decrypt the received value
if encryption_key is not None:
try:
response = self.decrypt(encryption_key, response)
except:
import traceback
traceback.print_exc()
pass
return response
else:
return None
def active(self, value=None, encryption_key="a", compress=None, just_name=False, liberty=True):
def decorate(value):
key = value.__name__
if value.__module__ != "__main__" and value.__module__ != None and not just_name:
key = value.__module__ + "." + key
self.set(key, value, encryption_key=encryption_key, compress=compress, liberty=liberty)
if value == None:
return decorate
else:
decorate(value)
return value

class Upsonic_On_Prem:
prevent_enable = False
quiet_startup = False
@staticmethod
def export_requirement():
the_list = list(freeze.freeze())
the_string = ""
for item in the_list:
the_string += item + ", "
return the_string[:-2]
def _log(self, message):
self.console.log(message)
def __enter__(self):
return self # pragma: no cover
def __exit__(self, exc_type, exc_val, exc_tb):
pass # pragma: no cover
def __init__(self, api_url, access_key):
import requests
from requests.auth import HTTPBasicAuth
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
from upsonic import console
self.console = console
self.requests = requests
self.HTTPBasicAuth = HTTPBasicAuth
self.api_url = api_url
self.password = access_key
self.enable_active = False
if self.status == True:
self._log(
f"[bold green]Upsonic[bold green] active",
)
else:
self._log(
f"[bold red]Upsonic[bold red] is down",
)
from upsonic import encrypt, decrypt
self.encrypt = encrypt
self.decrypt = decrypt
self.thread_number = 5
def _send_request(self, method, endpoint, data=None, make_json=True):
try:
response = self.requests.request(
method,
self.api_url + endpoint,
data=data,
auth=self.HTTPBasicAuth("", self.password),
verify=False,
)
try:
result = None
if not make_json:
result = response.text
else:
result = json.loads(response.text)
if result["status"] == False:
self._log(
f"[bold red]Error: {endpoint}",
)
else:
result = result["result"]
return result
except: # pragma: no cover
print(f"Error on '{self.api_url + endpoint}': ", response.text)
return [None] # pragma: no cover
except:
print("Error: Remote is down")
return [None]
@property
def status(self):
return self._send_request("GET", "/status")
def install_package(self, package):
from pip._internal import main as pip
package_name = package.split("==")[0]
package_version = (
package.split("==")[1]
if len(package.split("==")) > 1
else "Latest"
)
the_dir = os.path.abspath(
os.path.join(self.cache_dir, package_name, package_version)
)
if not os.path.exists(the_dir):
os.makedirs(the_dir)
pip(["install", package, "--target", the_dir])
@contextmanager
def import_package(self, package):
"""
import sys
for a in list(sys.modules):
if a.startswith("numpy"):
del sys.modules[a]
"""
package_name = package.split("==")[0]
package_version = (
package.split("==")[1]
if len(package.split("==")) > 1
else "Latest"
)
the_dir = os.path.abspath(
os.path.join(self.cache_dir, package_name, package_version)
)
if not os.path.exists(the_dir):
self.install_package(package)
sys_path_backup = sys.path.copy()
sys.path.insert(0, the_dir)
try:
yield
finally:
sys.path = sys_path_backup
def extend_global(self, name, value):
globals()[name] = value
def load_module(self, module_name, ):
encryption_key = "u"
the_all = self.get_all()
original_name = module_name
sub_module_name = False
if "." in module_name:
sub_module_name = module_name.replace(".", "_")
module_name = sub_module_name
the_all_imports = {}
for i in the_all:
original_i = i
if "_upsonic_" in i:
continue
if sub_module_name != False:
i = i.replace(original_name, module_name)
name = i.split(".")
if module_name == name[0]:
the_all_imports[i] = self.get(original_i)
import types
def create_module_obj(dictionary):
result = {}
for key, value in dictionary.items():
modules = key.split(".")
current_dict = result
for module in modules[:-1]:
if module not in current_dict:
current_dict[module] = types.ModuleType(module)
current_dict = vars(current_dict[module])
current_dict[modules[-1]] = value
return result
generated_library = create_module_obj(the_all_imports)[module_name]
return generated_library
def dump_module(
self,
module_name,
module,
):
encryption_key = "u"
top_module = module
cloudpickle.register_pickle_by_value(top_module)
sub_modules = []
if hasattr(top_module, "__path__"):
for importer, modname, ispkg in pkgutil.walk_packages(
path=top_module.__path__,
prefix=top_module.__name__ + ".",
onerror=lambda x: None,
):
sub_modules.append(
importer.find_module(modname).load_module(modname)
)
else:
sub_modules.append(top_module)
threads = []
the_list = []
for sub_module in sub_modules:
[
the_list.append(obj)
for name, obj in inspect.getmembers(sub_module)
]
# Extract just functions and classes
the_list = [
i for i in the_list if inspect.isfunction(i) or inspect.isclass(i)
]
# If the __module__ is not equal to module_name, remove it from the list
the_list = [
i for i in the_list if i.__module__.split(".")[0] == module_name
]
my_list = []
for element in copy.copy(the_list):
if inspect.isfunction(element):
name = element.__module__ + "." + element.__name__
elif inspect.isclass(element):
name = element.__module__ + "." + element.__name__
if (
not "upsonic.remote" in name
and not "upsonic_updater" in name
and name != f"{module.__name__}.threading.Thread"
):
my_list.append(element)
the_list = my_list
with Progress() as progress:
task1 = progress.add_task(
" [red]Job Started...", total=len(the_list)
)
task2 = progress.add_task(
" [green]Job Complated...", total=len(the_list)
)
for element in the_list:
time.sleep(0.1)
if inspect.isfunction(element):
name = element.__module__ + "." + element.__name__
elif inspect.isclass(element):
name = element.__module__ + "." + element.__name__
else:
continue
first_element = name.split(".")[0]
if first_element != module_name:
continue
try:
while len(threads) >= self.thread_number:
for each in threads:
if not each.is_alive():
threads.remove(each)
time.sleep(0.1)
the_thread = threading.Thread(
target=self.set,
args=(name, element),
)
the_thread.start()
thread = the_thread
threads.append(thread)
progress.update(task1, advance=1)
except:
import traceback
traceback.print_exc()
self._log(f"[bold red]Error on '{name}'")
self.delete(name)
for each in threads:
progress.update(task2, advance=1)
each.join()
def dump(
self,
key,
value,
):
return self.set(
key,
value,
)
def load(
self,
key,
):
return self.get(
key,
)
def set(
self,
key,
value,
):
the_type = type(value).__name__
if the_type == "type":
the_type = "class"
encryption_key = "u"
liberty = True
data = {
"scope": key,
"data": self.encrypt(encryption_key, value, liberty=liberty),
}
self._send_request("POST", "/dump", data)
data = {"scope": key, "type": the_type}
self._send_request("POST", "/dump_type", data)
data = {
"scope": key,
"code": textwrap.dedent(inspect.getsource(value)),
}
self._send_request("POST", "/dump_code", data)
data = {
"scope": key,
"requirements": Upsonic_On_Prem.export_requirement(),
}
self._send_request("POST", "/dump_requirements", data)
data = {
"scope": key,
"python_version": sys.version,
}
self._send_request("POST", "/dump_python_version", data)
return True
def get(
self,
key,
):
response = None
encryption_key = "u"
data = {"scope": key}
if response is None:
response = self._send_request("POST", "/load", data)
response = self.decrypt(encryption_key, response)
return response
def active(
self,
value=None,
):
encryption_key = "u"
def decorate(value):
key = value.__name__
if (
value.__module__ != "__main__"
and value.__module__ != None
and not just_name
):
key = value.__module__ + "." + key
self.set(
key,
value,
)
if value == None:
return decorate
else:
decorate(value)
return value
def get_all(self, ):
encryption_key = "u"
datas = self._send_request("GET", "/get_all_scopes_user")
return datas
def delete(self, key):
data = {"database_name": self.database_name, "key": key}
self.cache_pop(key)
return self._send_request("POST", "/controller/delete", data)
def database_list(self):
return ast.literal_eval(self._send_request("GET", "/database/list"))
def database_rename(self, database_name, new_database_name):
data = {
"database_name": database_name,
"new_database_name": new_database_name,
}
return self._send_request("POST", "/database/rename", data)
def database_pop(self, database_name):
data = {"database_name": database_name}
return self._send_request("POST", "/database/pop", data)
def database_pop_all(self):
return self._send_request("GET", "/database/pop_all")
def database_delete(self, database_name):
data = {"database_name": database_name}
return self._send_request("POST", "/database/delete", data)

Upsonic/CODE_OF_CONDUCT.md

Lines 100 to 127 in 5e10999

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at

Upsonic/CODE_OF_CONDUCT.md

Lines 50 to 100 in 5e10999

## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
info@upsonic.co.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public

# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.


Step 2: ⌨️ Coding

Modify README.md with contents:
• Begin by reviewing the current content of README.md to identify areas that require updates or improvements. This includes checking for outdated information, unclear instructions, or missing sections that are typically expected in a project README, such as "Installation", "Usage", "Contributing", and "License".
• Update the project description to ensure it accurately reflects the current state and goals of the Upsonic project. This might involve rewriting the introduction or adding more details about what makes Upsonic unique.
• Ensure there is a clear "Installation" section that provides step-by-step instructions on how to install Upsonic. This should include any prerequisites, supported platforms, and possibly a troubleshooting subsection for common installation issues.
• Add or refine the "Usage" section to include basic and advanced usage examples. Code snippets should be provided to help new users get started quickly. This section can also link to more detailed documentation if available.
• Review and update the "Contributing" section to provide clear guidelines on how users can contribute to the Upsonic project. This should include instructions on submitting issues, pull requests, and any coding standards or requirements.
• Ensure there is a "License" section that clearly states the project's license. Since the setup.py file mentions an MIT license, this should be reflected in the README as well.
• Optionally, add a "Community" or "Support" section where users can find help or discuss the project. This could include links to forums, a Discord server, or a mailing list.
• Throughout the README, ensure that all links are working and that any external resources mentioned are still relevant and accessible.
• Finally, proofread the README.md file for any spelling or grammatical errors to ensure it maintains a professional quality.
--- 
+++ 
@@ -45,7 +45,36 @@
 
 ## Usage
 
-Here's an updated quickstart guide to get you up and running with your container:
+Upsonic streamlines the development and deployment of utility libraries. Here's how to get started:
+
+### Basic Usage
+
+1. Initialize Upsonic with your server's address:
+   ```python
+   from upsonic import Upsonic_On_Prem
+   upsonic = Upsonic_On_Prem('https://your-server-address:5000', 'ACK_****************')
+   ```
+
+2. Define a function you wish to serialize and share:
+   ```python
+   def sum(a, b):
+       return a + b
+   ```
+
+3. Serialize the function for Upsonic:
+   ```python
+   upsonic.dump("math.basics.sum", sum)
+   ```
+
+4. Import and use the serialized function in another project:
+   ```python
+   math = upsonic.load_module("math")
+   math.basics.sum(5, 2)
+   ```
+
+### Advanced Usage
+
+For complex scenarios and advanced usage, refer to our [detailed documentation](https://docs.upsonic.co/home).
 
 ```python
 from upsonic import Upsonic_On_Prem
  • Running GitHub Actions for README.mdEdit
Check README.md with contents:

Ran GitHub Actions for f7ecd05c7f7181818a05296d496b51b8a20d4812:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/refactor_the_readme_fille.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description.
Something wrong? Let us know.

This is an automated message generated by Sweep AI.

@onuratakan onuratakan linked a pull request Mar 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant