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

✨ anomalist: improve utils #3385

Merged
merged 18 commits into from
Oct 9, 2024
Merged

Conversation

lucasrodes
Copy link
Member

@lucasrodes lucasrodes commented Oct 8, 2024

This PR re-organizes several grapher/db/s3 utils in our library.

We had some tools spread in multiple modules, within etl/ and in apps/. The idea is to compile these in centralised modules, so that it is easier to improve them, their maintenance, and enhancement.

Changes include:

  • etl.db: This module already existed but included a mixture of database utils and methods to query specific bits of data from our database. From now on, it should only include database utils.
  • etl.grapher_io: This is a new module, which should contain all our tools to access data/metadata (and possibly other bits of content) from our Grapher database/api (mysql/s3). The important bit here, is that it accesses non-etl content. Its content comes from various places: new content, from etl.db, from, apps.backport.datasync.data_metadata, etc.
  • etl.grapher_model: Added some functions to some ORM objects. For instance, class Variable has now a get_data method to access it's data (i.e. it accesses s3 data).

@lucasrodes lucasrodes changed the title wip ✨ anomalist: improve utils Oct 8, 2024
@owidbot
Copy link
Contributor

owidbot commented Oct 8, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-wizard-anomalies-utils

chart-diff: ✅ No charts for review.

Edited: 2024-10-08 14:45:06 UTC
Execution time: 3.76 seconds

@lucasrodes lucasrodes requested a review from Marigold October 9, 2024 09:23
@lucasrodes lucasrodes marked this pull request as ready for review October 9, 2024 09:23
return dataset_id


def get_variables_in_dataset(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, I think we should move this as a method to grapher_model.Dataset so that all dataset-related methods are in one place. (Not now though!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense. I've added a @deprecated tag



def get_variables_in_dataset(
dataset_id: int, only_used_in_charts: bool = False, db_conn: Optional[pymysql.Connection] = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db_conn should eventually also get deprecated. We should only use engine or session and read_sql function from db.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense. I've added a @deprecated tag

Copy link
Collaborator

@Marigold Marigold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, ship it!

@lucasrodes lucasrodes merged commit d2a7113 into wizard-anomalies Oct 9, 2024
7 of 8 checks passed
@lucasrodes lucasrodes deleted the wizard-anomalies-utils branch October 9, 2024 10:28
lucasrodes added a commit that referenced this pull request Oct 9, 2024
* ✨ wizard: anomalies

* wip

* bump streamlit

* wip

* wip: chart

* wip

* todo

* plot indicator

* re-structure

* wip: loading indicators

* fix API grapher_chart

* deprecate chart_html

* chart_html -> grapher_chart

* clean

* ci/cd

* wip

* wip

* changed module name

* custom components module

* add methods to get uris

* new alias

* get dataset uris

* update import

* update gpt pricing

* update import

* wip

* provide entity-context for anomaly

* wip: anomalist v2

* wip

* wip

* lock

* ✨ anomalist: improve utils (#3385)

* wip

* db -> db_utils

* io -> db

* move things db_utils -> db

* db -> grapher_io

* db -> grapher_io, db_utils -> db

* docstring

* db_utils -> db

* wip

* remove indicator

* add overloads

* ci/cd

* wip

* cicd

* wip

* deprecation warnings

* missing import

* hide anomalist in wizard
paarriagadap pushed a commit that referenced this pull request Oct 9, 2024
* ✨ wizard: anomalies

* wip

* bump streamlit

* wip

* wip: chart

* wip

* todo

* plot indicator

* re-structure

* wip: loading indicators

* fix API grapher_chart

* deprecate chart_html

* chart_html -> grapher_chart

* clean

* ci/cd

* wip

* wip

* changed module name

* custom components module

* add methods to get uris

* new alias

* get dataset uris

* update import

* update gpt pricing

* update import

* wip

* provide entity-context for anomaly

* wip: anomalist v2

* wip

* wip

* lock

* ✨ anomalist: improve utils (#3385)

* wip

* db -> db_utils

* io -> db

* move things db_utils -> db

* db -> grapher_io

* db -> grapher_io, db_utils -> db

* docstring

* db_utils -> db

* wip

* remove indicator

* add overloads

* ci/cd

* wip

* cicd

* wip

* deprecation warnings

* missing import

* hide anomalist in wizard
@lucasrodes lucasrodes mentioned this pull request Oct 7, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants