Skip to content

Frankfurter update #166

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jbrand-dsp
Copy link
Contributor

Adding the following for Frankfurter:

  • updated validation checks
  • integration tests
  • updated documentation

@@ -19,6 +19,11 @@ def get_path_with_retry(path: str) -> StrAny:
def validate_dates(start_date: datetime, end_date: datetime) -> None:
current_date = pendulum.now()

print("START DATE")
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove these debug print statements

dest_table,
)
assert result.exit_code != 0
assert has_exception(result.exception, ValueError)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be ingestr.src.errors.UnsupportedResourceError

Comment on lines 2997 to 3025
def interval_start_does_not_exceed_current_date(dest_uri):
schema = f"testschema_frankfurter_{get_random_string(5)}"
dest_table = f"{schema}.frankfurter_{get_random_string(5)}"
start_date = pendulum.now().add(days=1).format("YYYY-MM-DD")
result = invoke_ingest_command(
"frankfurter://",
"exchange_rates",
dest_uri,
dest_table,
interval_start=start_date,
)
assert result.exit_code != 0
assert has_exception(result.exception, ValueError)
assert "Interval-start cannot be in the future." in str(result.exception)


def interval_end_does_not_exceed_current_date(dest_uri):
schema = f"testschema_frankfurter_{get_random_string(5)}"
dest_table = f"{schema}.frankfurter_{get_random_string(5)}"
start_date = pendulum.now().subtract(days=1).format("YYYY-MM-DD")
end_date = pendulum.now().add(days=1).format("YYYY-MM-DD")
result = invoke_ingest_command(
"frankfurter://",
"exchange_rates",
dest_uri,
dest_table,
interval_start=start_date,
interval_end=end_date,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Although I like the idea of these tests, it can cause subtle issues for our users.

For instance, depending on which timezone frankfurter uses, the interval_end parameter may be valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

solutions:

  1. Remove --interval-end checks exceeding the current date. Users are responsible for providing the correct parameters.
    -- or --
  2. Figure out what timezone frankfurter uses and translate all date/time inputs to that timezone and then run validation on end date.

@@ -41,7 +41,9 @@ ingestr ingest \
### **`--interval-end` (Optional)**
- **Description**: The end date for fetching historical exchange rates.
- **Value**: A date in the format `YYYY-MM-DD` (e.g., `'2025-03-28'`).
- **Purpose**: Defines the ending point for fetching historical data. If not provided, it defaults to the value of `--interval-start`.
- **Purpose**: Defines the ending point for fetching historical data.
- If not provided, it defaults to the value of `--interval-start`.
Copy link
Contributor

Choose a reason for hiding this comment

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

--interval-end should be the current date. In fact, frankfurter treats a missing end date as the latest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was due to a design decision. Sabri suggested having a single historical date as part of exchange rates, as one is a subset of the other. I therefore diverged slightly from the API.

The easiest solution to this problem would be to require an end date or throw an exception.

A more involved solution would be to create follow the API and default to latest and to implement a table for a single historical date and call it something like historical_date. It would probably be a more elegant solution. I started the implementation and then realised I might just be creating more review work for you and more testing work for me.

What do you think?

Copy link
Contributor

@turtleDev turtleDev Apr 22, 2025

Choose a reason for hiding this comment

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

I see where you are coming from.

I can think of a few scenario's from a user's prespective:

  1. they need the latest exchange rate to covert currencies for online-transactions.
  2. they want to keep a historical record of currency rates

In case (1) the user will anyway use the latest resource. For (2) the user would probably want to have upto-date data from a specific starting point.

Can you think of any scenario where the user would want only a certain day's exchange rate? And if so, should that be the default expectation with everyone?

cc @sabrikaragonen

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.

2 participants