pepkit / pepdbagent

Database for storing sample metadata
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

V0.3.0 #63

Closed khoroshevskyi closed 1 year ago

khoroshevskyi commented 1 year ago

New 0.3.0 version of pepdbagent Main changes:

nsheff commented 1 year ago
nsheff commented 1 year ago

It's not clear what the search functions return in the documentation: image

Shouldn't it return a dict?

nsheff commented 1 year ago

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.

nsheff commented 1 year ago

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?

nleroy917 commented 1 year ago

Connection was my idea, oops!

nsheff commented 1 year ago

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?

khoroshevskyi commented 1 year ago

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.

nleroy917 commented 1 year ago

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.

nleroy917 commented 1 year ago

@Khoroshevskyi @nsheff

Notes from January 12th, 2023 meeting:

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()
nsheff commented 1 year ago
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)