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

Add the readme.md example dag to example dags folder #681

Merged
merged 7 commits into from
Sep 6, 2022
Merged

Conversation

utkarsharma2
Copy link
Collaborator

Description

What is the current behavior?

Currently, we have examples in the README.md file which are not getting tested as we update the code.

closes: #680

What is the new behavior?

We can move our code to example_dags and refer to that file in README.md so that this file is tested with every change.

Does this introduce a breaking change?

Nope

Checklist

  • All checks and tests in the CI should pass
  • Example DAG
  • Improve the documentation (README, Sphinx, and any other relevant)

@utkarsharma2 utkarsharma2 changed the title Ref codein md Add the readme.md example dag to example dags folder Aug 18, 2022
Copy link
Contributor

@sunank200 sunank200 left a comment

Choose a reason for hiding this comment

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

Isn't this DAG just a subset of https://github.com/astronomer/astro-sdk/blob/main/example_dags/example_transform.py ?

We could just use that. WDYT?

example_dags/calculate_popular_movies.py Outdated Show resolved Hide resolved
Copy link
Member

@feluelle feluelle left a comment

Choose a reason for hiding this comment

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

For me it is not showing the whole code at once. I would have to scroll down to see everything. :/

Screenshot 2022-08-18 at 11 57 37

@utkarsharma2
Copy link
Collaborator Author

utkarsharma2 commented Aug 18, 2022

For me it is not showing the whole code at once. I would have to scroll down to see everything. :/

Screenshot 2022-08-18 at 11 57 37

@feluelle I didn't see any way to change the size of the code snippet. I'll check and get back.

README.md Outdated
),
)
```
https://github.com/astronomer/astro-sdk/blob/d5aa768b2d4bca72ef98f8d533fe3f99624b172f/example_dags/calculate_popular_movies.py#L1-L37
Copy link
Collaborator

@kaxil kaxil Aug 18, 2022

Choose a reason for hiding this comment

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

WDYT about the following instead, thoughts? cc @kentdanas @feluelle @mikeshwe @jwitz

Suggested change
https://github.com/astronomer/astro-sdk/blob/d5aa768b2d4bca72ef98f8d533fe3f99624b172f/example_dags/calculate_popular_movies.py#L1-L37
curl -O https://raw.githubusercontent.com/astronomer/astro-sdk/main/example_dags/calculate_popular_movies.py

README.md Outdated
@@ -50,42 +50,7 @@ pip install astro-sdk-python[amazon,google,snowflake,postgres]

1. Copy the following DAG into a file named `calculate_popular_movies.py` and add it to the `dags` directory of your Airflow project:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd actually prefer if we kept the DAG code visible in the README. Even though it's longer, the reader won't have to click into another page/ run a command before they see how the SDK works. We can still keep the other DAG file, but this would serve as the window into what the SDK can do

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we could embed the code it would be the best scenario from both perspectives

from astro.files import File
from astro.sql.table import Table

@aql.transform()
Copy link
Contributor

Choose a reason for hiding this comment

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

If we add this back to the README as code, it would be great to add some more inline comments about what the code/ SDK is doing here.

@kaxil kaxil added this to the 1.1.0 milestone Aug 18, 2022
README.md Outdated
),
)
```
curl -O https://raw.githubusercontent.com/astronomer/astro-sdk/main/example_dags/calculate_popular_movies.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

@utkarsharma2 why did you favour this approach instead of adding the code snipped with permalink? Is it because the permalink would have the version of the code hard-coded?

Copy link
Member

Choose a reason for hiding this comment

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

I would use the permalink, otherwise we could end up having a 404 (completely missing) in our README.

Copy link
Collaborator Author

@utkarsharma2 utkarsharma2 Sep 6, 2022

Choose a reason for hiding this comment

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

@tatiana @feluelle initially permalinks was my approach - 21f7bd8#r949124948

But I guess @kaxil felt the alternative would be better. I personally inclined towards the permalinks approach.

refer below link for that discussion - #681 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I felt that mainly because users would otherwise have to copy/paste it and because of scrolling involved with code-snippet that might result in issues.

However, if all of you think snippet + permalink is a better approach then go for it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@utkarsharma2 What if we kept both of them? The code snipped & the curl command - so we would meet the requirement from the doc team while also simplifying for those who may want to download it straightway - without having to have the code hard-coded in the README?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tatiana I think we can keep both if we are able to verify the curl link is working. Just a little worried if move the file somewhere else and the links are broken.

Copy link
Collaborator Author

@utkarsharma2 utkarsharma2 Sep 6, 2022

Choose a reason for hiding this comment

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

@tatiana Never mind - CI job takes care of that - gaurav-nelson/github-action-markdown-link-check@v1. I'm going ahead with adding both.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated:

Screenshot 2022-09-07 at 2 34 48 AM

Copy link
Member

Choose a reason for hiding this comment

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

Never mind - CI job takes care of that - gaurav-nelson/github-action-markdown-link-check@v1. I'm going ahead with adding both.

Right. That's great! +1 for using main version.

README.md Outdated
imdb_movies = aql.load_file(imdb_src, imdb_movies)
https://github.com/astronomer/astro-sdk/blob/d5aa768b2d4bca72ef98f8d533fe3f99624b172f/example_dags/calculate_popular_movies.py#L1-L37

Alternatively you can download the file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Alternatively you can download the file
Alternatively, you can download the file by running:

README.md Outdated
Comment on lines 71 to 75
4. Ensure that your Airflow environment is set up correctly by running the following commands:

top_animations = Table(name="top_animation")
top_animations = top_five_animations(input_table=imdb_movies, output_table=top_animations)
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't fully understand this part. Do we need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tatiana yes, we do, was a typo fixed it.

@codecov
Copy link

codecov bot commented Sep 6, 2022

Codecov Report

Merging #681 (815a607) into main (1f5f16c) will not change coverage.
The diff coverage is n/a.

❗ Current head 815a607 differs from pull request most recent head 6274b25. Consider uploading reports for the commit 6274b25 to get more accurate results

@@           Coverage Diff           @@
##             main     #681   +/-   ##
=======================================
  Coverage   93.26%   93.26%           
=======================================
  Files          43       43           
  Lines        1855     1855           
  Branches      232      232           
=======================================
  Hits         1730     1730           
  Misses         97       97           
  Partials       28       28           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@utkarsharma2 utkarsharma2 merged commit 62303bd into main Sep 6, 2022
@utkarsharma2 utkarsharma2 deleted the RefCodeinMd branch September 6, 2022 21:26
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.

Move dag example in README.md in example_dags
6 participants