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

Make antlr optional #423

Merged
merged 6 commits into from
Sep 26, 2024
Merged

Make antlr optional #423

merged 6 commits into from
Sep 26, 2024

Conversation

ocefpaf
Copy link
Member

@ocefpaf ocefpaf commented Apr 23, 2024

Closes #313

@CLAassistant
Copy link

CLAassistant commented Apr 23, 2024

CLA assistant check
All committers have signed the CLA.

@ocefpaf ocefpaf marked this pull request as ready for review April 23, 2024 15:33
@ocefpaf
Copy link
Member Author

ocefpaf commented Apr 23, 2024

I wanted to add a test without antlr-python-runtime but I have no idea how to do that in the complex tox/conda-lock/extra env file setup here. If someone wants to add that note that we would need to call pytest with pytest cf_units/tests to avoid collecting import errors, or use -continue-on-collection-errors to continue.

I can attest that this works. All the functionalities but latex parsing are available and the import error is informative enough, if/when someone tries to use latex.

@pp-mo
Copy link
Member

pp-mo commented Sep 12, 2024

NOTE: update thoughts
Despite the exciting possibilities of #445 and a possible stepping-stone to #446,
that doesn't make a reason to not do this first -- it's still a useful + a simple first step.

@pp-mo
Copy link
Member

pp-mo commented Sep 13, 2024

Status update 2024/9/13 :
this is a good change, but can't just resolve + merge.
Want to incorporate changes to the env ymls, and then re-resolve the lockfiles

@ocefpaf
Copy link
Member Author

ocefpaf commented Sep 13, 2024

it's still a useful + a simple first step.

That would help a lot while we wait for something better.

but can't just resolve + merge.
Want to incorporate changes to the env ymls, and then re-resolve the lockfiles

I confess that the CI setup here grow both in complexity and size that makes me not want to mess with them. Even more so in a case for an optional dependency, which can increase the number of files here. Is that something that is on your radar or as you expecting me, as the PR author, to do it? If the latter, I'd love some guidance before I tackle this.

@trexfeathers
Copy link
Collaborator

I confess that the CI setup here grow both in complexity and size that makes me not want to mess with them. Even more so in a case for an optional dependency, which can increase the number of files here. Is that something that is on your radar or as you expecting me, as the PR author, to do it? If the latter, I'd love some guidance before I tackle this.

Hi @ocefpaf, we definitely agree that things have become complex!

Your PR does not need to do anything with lock files

  • For testing purposes we make no distinction between core and optional dependencies. This only matters for Pip (i.e. setup.cfg) and Conda (the person updating the feedstock reads cf-units.yml). So no lock-file updates needed.
  • Since you raised this, we had a conflicting PR that was also adding Python 3.12, so we've merged that into main and I've updated your branch.

Complexity for developers

The intention is that the complexity is handled by the tox -e py*-lock environments, and that the developer can just commit the results without worrying about them. In future we might even get that to run automatically on any PR that changes cf-units.yml.

We adopted Tox specifically thinking of developers like you, who we don't talk to every day - we want to use familiar tools so we don't need to explain our repo structure to collaborators. What do you think we could we do to make things clearer?

@trexfeathers
Copy link
Collaborator

I wanted to add a test without antlr-python-runtime but I have no idea how to do that in the complex tox/conda-lock/extra env file setup here.

Yes, we have (I think) no experience in structuring tests to confirm correct handling of optional dependencies. For instance I can't find any test coverage for this line in Iris.

It doesn't look like PyTest has any built-in conveniences for 'hiding' a dependency for the duration of test(s), but it might be possible using mocking? We're certainly not interested in creating more lock files than we have already. Would love to know your thoughts.

@trexfeathers
Copy link
Collaborator

I wanted to add a test without antlr-python-runtime but I have no idea how to do that in the complex tox/conda-lock/extra env file setup here.

Yes, we have (I think) no experience in structuring tests to confirm correct handling of optional dependencies. For instance I can't find any test coverage for this line in Iris.

It doesn't look like PyTest has any built-in conveniences for 'hiding' a dependency for the duration of test(s), but it might be possible using mocking? We're certainly not interested in creating more lock files than we have already. Would love to know your thoughts.

I will do my best to get this over the line either way, even if that means raising an issue to add tests in future.

@trexfeathers
Copy link
Collaborator

I will do my best to get this over the line either way, even if that means raising an issue to add tests in future.

#485

@pelson
Copy link
Member

pelson commented Sep 26, 2024

The follow-on test infrastructure has quite a cost, when compared to my proposal in #313 (comment):

perhaps just vendoring the runtime (all 150kb of it) is the way to go?

The code is BSD and is pure Python, but it appears to not use relative imports (making it a bit harder to vendor as you have to do a search and replace). The outcome would be no dependency at all, and the tests would validate that the behaviour is as expected.

Copy link
Member

@pp-mo pp-mo left a comment

Choose a reason for hiding this comment

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

OK I think this is good to merge as-is.
Since we are still installing antlr + running tests, we know this does not break status quo. That's good enough for a start IMHO.

The follow-on #485 is a nice-to have, but not an essential prerequisite.
For sanity we can do a one-off test to check that, right now, cf_units does function without antlr.

@pp-mo pp-mo merged commit d22c5ea into SciTools:main Sep 26, 2024
14 checks passed
@pp-mo
Copy link
Member

pp-mo commented Sep 26, 2024

Since Iris does not currently use the cf_units "tex" function, there should be no need to include this in the Iris dependencies either for testing or runtime (i.e. in the recipe on the iris conda-forge feedstock).
That could change if we move to 'tex()' in iris plots -- we then need to add antlr4-runtime as an Iris test dependency.
Meanwhile, the functionality is still tested here in cf_units, so should not go stale.

@ocefpaf ocefpaf deleted the make_antlr_optional branch September 26, 2024 11:48
stephenworsley added a commit to stephenworsley/cf-units that referenced this pull request Sep 27, 2024
* main:
  [DOCS] Update docstring for date2num (module function) (SciTools#483)
  Modernise setup scripts (SciTools#484)
  Make antlr optional (SciTools#423)
  Ruff: smaller steps (SciTools#364)
  Updated docstring for num2date. (SciTools#467)
  updated conda lock files (SciTools#479)
  Revert to 00:03 Mondays for lockfile updates. (SciTools#480)
  New trigger time for GMT. (SciTools#478)
  Check lockfile updates @ 3pm daily (temporary for testing). (SciTools#477)
  Fixlocks (SciTools#470)

# Conflicts:
#	pyproject.toml
#	requirements/cf-units.yml
#	requirements/locks/py310-lock-linux-64.txt
#	requirements/locks/py310-lock-osx-64.txt
#	requirements/locks/py310-lock-win-64.txt
#	requirements/locks/py311-lock-linux-64.txt
#	requirements/locks/py311-lock-osx-64.txt
#	requirements/locks/py311-lock-win-64.txt
#	requirements/locks/py312-lock-linux-64.txt
#	requirements/locks/py312-lock-osx-64.txt
#	requirements/locks/py312-lock-win-64.txt
@thebaptiste
Copy link

Can we hope a new release with antlr optional soon on pypi ?
Thanks

@pp-mo
Copy link
Member

pp-mo commented Oct 3, 2024

Can we hope a new release with antlr optional soon on pypi ? Thanks

I think we're now leaning towards #487 instead.
Presumably that would suit you just as well @thebaptiste ?

But anyway a release before long, though we're not committing to a date yet.

@thebaptiste
Copy link

thebaptiste commented Oct 3, 2024

I think we're now leaning towards #487 instead. Presumably that would suit you just as well @thebaptiste ?

Yes, it would suit me, as long as there is no longer a dependency on such an old release (4.7.2) of antlr4-runtime-library.
No dependency at all, vendoring it, is even better !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can we make antlr4-python3-runtime==4.7.2 dependency optional?
7 participants