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

Modernize carbon flux #411

Merged
merged 24 commits into from
Nov 14, 2024
Merged

Modernize carbon flux #411

merged 24 commits into from
Nov 14, 2024

Conversation

Azaya89
Copy link
Collaborator

@Azaya89 Azaya89 commented Aug 6, 2024

Modernizing an example checklist

Preliminary checks

  • Look for open PRs and issues that reference the project you are updating. It is possible previous unmerged work in PR could be re-used to modernize the project. Comment on these PRs and issues when appropriate, hopefully we should be able to close some of them after your modernizing work.

Change ‘anaconda-project.yml’ to use the latest workable version of packages

  • Pin python=3.11
  • Remove the upper pin (e.g. hvplot<0.9 to hvplot, panel>=0.12,<1.0 to panel>=0.12) of all other dependencies. Removing the upper pins of dependencies could necessitate code revisions in the notebooks to address any errors encountered in the updated environment. Should complexities or extensive time requirements arise, document issues for team discussion on whether to re-pin specific packages or explore other solutions.
  • Add/update the lower pin of all other dependencies (e.g. hvplot to hvplot>=0.9.2, hvplot>=0.8 to hvplot>=0.9.2). Usually, the new/updated lower pin of a dependency will be the version resolved after anaconda prepare has been run. Execute !conda list in a notebook, or anaconda run conda list in the terminal, to display the version of each dependency installed in the environment. Adjusting the lower pin helps ensure that the locks produced for each platform (linux-64, win-64, osx-64, osx-arm64) rely on the tested dependencies and not on some older versions.
  • If one of the channels include conda-forge or pyviz, ask Maxime if it can be removed

Plot API updates (discussed on a per-example basis)

  • Generally, try to replace HoloViews usage with hvPlot. At a certain point of complexity, such as with the use of ‘.select’, it might be better to stick with HoloViews. Additional examples of ‘complexity boundaries’ should be documented in this document.
  • Almost always, try to replace the use of datashade with rasterize (read this page). Essentially, rasterize allows Bokeh to handle the colormapping instead of Datashader.

Interactivity API updates (discussed on a per-example basis)

  • Remove all pn.interact usage
  • Avoid .param.watch() usage. This is pretty low-level and verbose approach and should not be used in Examples unless required, or an Example is specifically trying to demo its usage in an advanced workflow.
  • Prefer using pn.bind(). Read this page for explanation.
  • For apps built using a class approach, when they create a view() method and call it directly, update the class by inheriting from pn.viewable.Viewer and replace view() by __panel__(). Here is an example.

Panel App updates (discussed on a per-example basis)

  • If the project doesn’t at any point create a Panel app at all, consider creating one. It can be as simple as wrapping a plot in pn.Column, or more complicated to incorporate widgets, etc. Make the final app .servable().
  • If the project creates an app in a notebook but doesn’t deploy it (i.e. there is no command: dashboard declaration in the anaconda-project.yml file), try adding it.
  • If the project already deploys an app but doesn’t wrap it in a nice template, consider wrapping it in a template.
  • If the project deploys an app wrapped in a template, customize the template a little so all the apps don’t look similar (e.g. change the header background color). This doesn’t need to be discussed.
  • Comment start If you are building the application in a single cell, you can construct a template explicitly, like template = pn.template.BootstrampTemplate, but if building up an app across multiple cells, it is probably cleaner to declare the template at the top with pn.extension(template='bootstrap'). See how to guide on setting a template.

General code quality updates

  • If the notebook disables warnings (e.g. with warnings.simplefilter(‘ignore’) somewhere at the start of the notebook, remove this line. Try to update the code to remove the warnings, if any. If updating the code to remove the warnings is taking significant amount of time and effort, bring it up for discussion and we may decide to disable warnings again.

Text content

  • Edit the text content anywhere and everywhere that it can be improved for clarity.
  • Check the links are valid, and update old links (e.g. http -> https, xyz.pyviz.org -> xyz.holoviz.org)
  • Remove instructions to install packages inside an example

Visual appearance - Example

  • Check that the titles/headings make sense and are succinct.
  • Check that the text content blocks are easily readable; revise into additional paragraphs if needed.
  • Check that the code blocks are easily readable; revise as needed. (e.g. add spaces after commas in a list if there are none, wrap long lines, etc.)
  • Check image and plot sizes. If possible, making them responsive is highly recommended.
  • Check the appearance on a smartphone (check Google to see how to adapt the appearance of your browser to display pages as if they were seen from a smartphone, this is usually done via the web developer tools). This is not a top priority for all examples, but if there are a few easy and straightforward changes to make that can improve the experience, let’s do it.
  • Check the updated notebook with the original notebook

Visual appearance - Gallery

  • Check the thumbnail is visually appealing
  • Check the project title is well formatted (e.g. Ml Annotators to ML Annotators), if not, add/update the examples_config.title field in anaconda-project.yml
  • Check the project description is appropriate, if not, update the description field in anaconda-project.yml

Workflow (after you have made the changes above)

  • Run successfully doit validate:<projectname>
  • Run successfully doit test:<projectname>
  • Run successfully doit doc_one –name <projectname>. It’s better if the project notebook(s) is saved with its outputs (but be sure to clear outputs before committing to the examples repo!) when building the docs. Then open this file in your browser ./builtdocs/index.html and check how the site looks.
  • If you’re happy with all the above, open a PR. Reminder, clear notebook outputs before pushing to the PR.

@Azaya89 Azaya89 self-assigned this Aug 6, 2024
@Azaya89
Copy link
Collaborator Author

Azaya89 commented Aug 6, 2024

This is still a WIP. Not ready for review yet.

@Azaya89 Azaya89 added the NF SDG NumFocus Software Development Grant 2024 label Aug 7, 2024
@Azaya89

This comment was marked as outdated.

@Azaya89 Azaya89 requested review from maximlt and droumis August 9, 2024 06:40
@Azaya89 Azaya89 force-pushed the modernize_carbon_flux branch 2 times, most recently from 05c8c03 to 7a11f06 Compare October 18, 2024 16:01
@Azaya89
Copy link
Collaborator Author

Azaya89 commented Oct 18, 2024

  1. I have completely re-wrote the notebook to remove all usage of intake.

  2. The .csv files are downloaded locally via awscli by running anaconda-project run download_fluxnet_daily. This takes about a minute to download all the files and saves in the same folder as the .txt file.

  3. Some of the cells are failing the test now and I don't know why. I will investigate that later.

Otherwise, I think this is ready for review now.

@hoxbro

@hoxbro
Copy link
Contributor

hoxbro commented Nov 4, 2024

I have pushed a fix that will make the test pass. I'm unsure why it doesn't work when you scatter the index.

The doc build is failing; @Azaya89, can you try and see if you can fix this?

@maximlt
Copy link
Contributor

maximlt commented Nov 5, 2024

Arf @Azaya89 I see we're still having some issues. The error we encounter looks very similar to the one reported here aws/aws-cli#8988. Digging more into this direction should hopefully give us a solution. This for instance looks promising aws/aws-cli#5623 (comment), this too https://stackoverflow.com/questions/64992288/s3-sync-issue-running-in-azure-devops-pipeline-on-linux.

@Azaya89
Copy link
Collaborator Author

Azaya89 commented Nov 5, 2024

Arf @Azaya89 I see we're still having some issues. The error we encounter looks very similar to the one reported here aws/aws-cli#8988. Digging more into this direction should hopefully give us a solution. This for instance looks promising aws/aws-cli#5623 (comment), this too https://stackoverflow.com/questions/64992288/s3-sync-issue-running-in-azure-devops-pipeline-on-linux.

Thank you. Let me try this out...

Copy link
Contributor

github-actions bot commented Nov 5, 2024

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR.

@Azaya89
Copy link
Collaborator Author

Azaya89 commented Nov 5, 2024

The doc build is failing; @Azaya89, can you try and see if you can fix this?

Fixed. I think it is ready for final review now @hoxbro

carbon_flux/carbon_flux.ipynb Outdated Show resolved Hide resolved
carbon_flux/carbon_flux.ipynb Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR.

Copy link
Contributor

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

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

Another run has replaced the dev docs site. I want to make sure you checked if everything looked good before it was replaced.

" try:\n",
" dd = cat.fluxnet_daily(s3_path=s3_path.split('/')[-1]).to_dask()\n",
" except FileNotFoundError:\n",
" df = dd.read_csv(\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: It is common to use ddf for dask DataFrame.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. Done

Copy link
Contributor

@maximlt maximlt left a comment

Choose a reason for hiding this comment

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

I'm sorry I wrote this comment a while back but forgot to submit it! There are some dependencies that shouldn't be included in the project file.

- aiobotocore=1.2.2
- numba >=0.60.0
- numpy >=1.26.4
- jinja2 >=3.1.4
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think pinning jinja2 is required. Please review the packages list and remove the unnecessary ones like this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR.

@Azaya89
Copy link
Collaborator Author

Azaya89 commented Nov 13, 2024

Another run has replaced the dev docs site. I want to make sure you checked if everything looked good before it was replaced.

LGTM!

Copy link
Contributor

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR.

@Azaya89 Azaya89 merged commit b7b3a5c into main Nov 14, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NF SDG NumFocus Software Development Grant 2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants