Closed khoroshevskyi closed 1 year ago
models.py
to explain what it is_count_find_project
It's not clear what the search functions return in the documentation:
Shouldn't it return a dict?
I think you should rename the Connection
object -- objects named connection
or con
are typically used to hold a connection to a database. In this case, though, it's not that -- it's more specific to a PEP database. This is confusing to me.
It should be, maybe, PEPDBConnection
, for example. Or, since it's not just a connection but does lots of stuff, PEPDBAgent
.
Where is the Agent
object in this, anyway?
Connection
was my idea, oops!
I don't understand why you made Connection and Search two different subclasses of BaseConnection.
Wouldn't you just have an Agent class with a connection, that held instances of the sub-classes?
I don't understand why you made Connection and Search two different subclasses of BaseConnection.
I did it because we had duplicated function in two classes. So Base class holds this functions.
Wouldn't you just have an Agent class with a connection, that held instances of the sub-classes?
If I understood you correctly: You suggest to have all methods in one function, right? I divided this functionality for two classes, to make code more understandable, and to not mix all functions.
I don't understand why you made Connection and Search two different subclasses of BaseConnection.
This was my recommendation. I noticed he was duplicating code for the Search
and Connection
class, so I recommended make a base class that holds the _run_sql_fetchall
type code.
@Khoroshevskyi @nsheff
pepdbagent
and change class to PEPDatabaseAgent
Why are Search
and PEPDatabaseAgent
two different classes?
PEPDatabaseAgent
class:
class Connection():
def __init__(self, host: str = "localhost", port: int = 5432, ...):
self.host = host
class Search(): def init(self, conn): self._conn = conn
def search_for_project(self, query: str):
self.conn._run_sql_fetchall(f"select * from projects where ...")
class PEPDatabaseAgent(): def init(self): self.conn = Connection() self.search = Search(self.conn)
db_agent = PEPDatabaseAgent() db_agent.conn.get_project("nleroy917/basic") db_agent.search.search_for_project("nleroy917")
- Change naming in the search class:
- count_project()
- get_projects()
- count_namespaces()
- get_projects()
db_agent.namespace.get(limit=x, offset=0) # all namespaces, { limit: x, offset: y, count: n, items: {...}}
db_agent.namespace.get(query="<query_string>", limit=x, offset=0) # search namespaces, return { limit: x, offset: y, count: n, items: {...}}
db_agent.annotation.get(namespace=None, project_name=None, tag=None, limit=x, offset=0, query="<str>") # returns { limit: x, offset: y, count: n, items: {...}}
db_agent.annotation.get_by_rp(registry_paths, limit=x, offset=0) # { limit: x, offset: y, count: n, items: {...}}
db_agent.project.get_by_rp(registry_path) #
db_agent.project.get(namespace, project_name, tag)
New 0.3.0 version of pepdbagent Main changes:
private
,number_of_samples
,submission_date
,last_update_date
), and deleted annotation column (we didn't need it).