53 Commits

Author SHA1 Message Date
Javan Lacerda
8e07445597
Adding clusterfuzz-config commit sha to revision (#4716)
Adding clusterfuzz-config commit hash to the revision. It will help
during tracing sessions.

<img width="784" alt="image"
src="https://github.com/user-attachments/assets/3835142a-1a39-49d2-bd5e-0e45ba55507d"
/>

---------

Signed-off-by: Javan Lacerda <javanlacerda@google.com>
2025-03-11 10:11:44 -03:00
Titouan Rigoudy
6a8393723e
Update pyright to 1.1.393 and type-checking python version to 3.11 (#4655)
Bumps the version of Python used for type-checking to 3.11. That is to
say, pyright now supports type-checking idioms that were introduced
after 3.7 like `FooType | None`.

Regenerated `Pipfile.lock` after updating `Pipfile` using `pipenv lock --dev --keep-outdated`.
2025-02-03 18:31:25 +01:00
Titouan Rigoudy
430e423d51
Add pyright support. (#3452)
Adds support for type checking python code using pyright.

Also adds a dependency on `mypy-protobuf` in order to generate `.pyi`
type stubs for generated protobuf code, without which the type checker
gets very confused.

pyright was chosen because it seems like the leading python type checker
these days, and because it has broad python3 version support.

This PR also integrates pyright with `butler.py lint`, such that changed
files can optionally be type-checked if the `--type-check` command-line
argument is set. This allows for local experimentation before we decide
on the next steps.
2024-09-03 10:07:24 +10:00
Vitor Guidi
d5fb5f6264
Attempting to bump proto/grpcio in Python 3.7 - 3rd attempt (#4066)
### Motivation

Last attempted was
[reverted](https://github.com/google/clusterfuzz/pull/4064) due to an
issue in utask main scheduler, related to protos and gcp batch

This PR attempts to fix the following issue:

```
AttributeError: Unknown field for InstancePolicy: boot_disk

at .__setattr__ ( /mnt/scratch0/clusterfuzz/src/third_party/proto/message.py:932 )
at ._get_allocation_policy ( /mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/google_cloud_utils/batch.py:182 )
at ._create_job ( /mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/google_cloud_utils/batch.py:225 )
at .create_uworker_main_batch_jobs ( /mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/google_cloud_utils/batch.py:139 )
at .schedule_utask_mains ( /mnt/scratch0/clusterfuzz/src/python/bot/startup/run_bot.py:105 )
at .task_loop ( /mnt/scratch0/clusterfuzz/src/python/bot/startup/run_bot.py:136 )
```

### Testing strategy

This issue was caused because batch was set to 0.2.0, and the boot_disk
proto field was only [introduced in
0.6.0](https://cloud.google.com/python/docs/reference/batch/latest/changelog).
Returning the dependency to 0.11.0 solved the issue. This was tested
manually through
[use_batch.py](bcae6b19f3/src/clusterfuzz/_internal/tests/core/google_cloud_utils/use_batch.py (L4)),
pointing to our internal gcp service.

Evidence that a batch job is successfully created:


![image](https://github.com/google/clusterfuzz/assets/5733577/85b8c476-e1c0-4e89-b5ce-3c2d0d1cc578)


![image](https://github.com/google/clusterfuzz/assets/5733577/39469891-0a5c-4d66-ae81-c12240a08c6f)
2024-06-28 13:30:00 -03:00
jonathanmetzman
bcae6b19f3
Revert "Chore/py37 proto bump reattempt (#4062)" (#4064)
This reverts commit 7e57e8821d35ec2b12c957239ae75c9bf33964f7.

New error:
```
AttributeError: Unknown field for InstancePolicy: boot_disk

at .__setattr__ ( /mnt/scratch0/clusterfuzz/src/third_party/proto/message.py:932 )
at ._get_allocation_policy ( /mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/google_cloud_utils/batch.py:182 )
at ._create_job ( /mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/google_cloud_utils/batch.py:225 )
at .create_uworker_main_batch_jobs ( /mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/google_cloud_utils/batch.py:139 )
at .schedule_utask_mains ( /mnt/scratch0/clusterfuzz/src/python/bot/startup/run_bot.py:105 )
at .task_loop ( /mnt/scratch0/clusterfuzz/src/python/bot/startup/run_bot.py:136 )
```
2024-06-27 10:25:17 -04:00
Vitor Guidi
7e57e8821d
Chore/py37 proto bump reattempt (#4062)
Reattempt at #4029 

This PR belongs to [this
initiative](https://github.com/google/clusterfuzz/issues/4059)
2024-06-26 18:33:42 -03:00
jonathanmetzman
62090e4830
Revert changes to upgrade packages. (#4061)
They are broken in prod causing this error:

https://pantheon.corp.google.com/errors/detail/CPv0x-n-iqv-jQE?e=-13802955&mods=logs_tg_prod&project=google.com:clusterfuzz
```
Unable to update heartbeat.
Traceback (most recent call last):
  File "/mnt/scratch0/clusterfuzz/src/clusterfuzz/_internal/datastore/data_handler.py", line 1130, in update_heartbeat
    heartbeat = ndb.Key(data_types.Heartbeat, bot_name).get()
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/_options.py", line 102, in wrapper
    return wrapped(*pass_args, **kwargs)
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/utils.py", line 150, in positional_wrapper
    return wrapped(*args, **kwds)
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/key.py", line 859, in get
    return self.get_async(_options=_options).result()
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/tasklets.py", line 210, in result
    self.check_success()
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/tasklets.py", line 157, in check_success
    raise self._exception
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/tasklets.py", line 319, in _advance_tasklet
    yielded = self.generator.throw(type(error), error, traceback)
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/key.py", line 944, in get
    entity_pb = yield _datastore_api.lookup(self._key, _options)
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/tasklets.py", line 323, in _advance_tasklet
    yielded = self.generator.send(send_value)
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/_datastore_api.py", line 165, in lookup
    entity_pb = yield batch.add(key)
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/ndb/_datastore_api.py", line 217, in add
    todo_key = key.to_protobuf()._pb.SerializeToString()
  File "/mnt/scratch0/clusterfuzz/src/third_party/google/cloud/datastore/key.py", line 324, in to_protobuf
    key.path.append(element)
TypeError: Parameter to MergeFrom() must be instance of same class: expected google.datastore.v1.Key.PathElement got PathElement.
```
Vitor says this isn't a deterministic bug.
2024-06-24 10:10:49 -04:00
Vitor Guidi
a16f837484
Chore/bump py37 deps (#4029)
*** Motivation
This PR complements #4005 by bumping the gcp clients, grpcio and
protobuf, and fixing the code to accomodate for breaking changes.
2024-06-17 13:17:47 -03:00
Vitor Guidi
68257d9fa9 Bumping deps to an intermediary step compatible with Python3.11 (#4005)
Some of our current dependencies are incompatible with Python 3.11. This
PR attempts to bump the least possible amount of dependencies (more
specifically, grpcio, grpcio-tools, psutil and markupsafe), so we can
isolate deployment issues between dependency bumps and the python
upgrade itself.
2024-06-07 12:41:29 -04:00
jonathanmetzman
0c476dec38
Set initial task name as task name when updating comments. (#3802)
So that users see e.g. when minimized task ends, not
that postprocess ends.
2024-03-05 11:10:39 -05:00
jonathanmetzman
cee5a6b60e
Reinstall future. (#3704)
Some fuzzers depend on it.
2024-02-01 13:37:07 -05:00
Ali HIJAZI
ab4dbb6c7b
Use protos directly in utasks (#3536)
This change removes the uworker_io wrappers and uses protos directly
within the utasks. This change also removes the Json user defined proto.
2023-12-11 01:33:13 -05:00
Jonathan Metzman
f2977550f5 Revert "[Python3.11] Upgrade grpc (#3397)"
This reverts commit e0bf80ee1ab1f05f4c6313ed0458d9c5ee0f3657.

Not available on Python3.7
2023-10-05 12:05:47 -04:00
jonathanmetzman
e0bf80ee1a
[Python3.11] Upgrade grpc (#3397)
Do this so that we don't need to upgrade when upgrading Python3.11 and
we can isolate the source of any bugs.

Redo upgrade reverted by #3264
2023-10-05 09:01:54 -04:00
jonathanmetzman
dddc361c04
[python upgrade] Upgrade test-only packages (#3376)
This will make it possible to upgrade to Python3.11 Relands changes
reverted in #3264.
2023-10-02 15:12:15 -04:00
jonathanmetzman
9eca256eb8
Downgrade to Python3.7 (#3264)
We don't have the time to monitor this, let's downgrade for now to
unblock deploys.
2023-08-03 08:18:24 -04:00
jonathanmetzman
bb33f5170d
Upgrade psutil to 5.9.5 to get wheel Python3.11. (#3251)
I think I must've installed a newer psutil to get this working last
time.
https://github.com/giampaolo/psutil/issues/2165
I've confirmed this works on a linux machine without a compiler 
CC @mihaimaruseac
2023-07-25 19:17:36 -04:00
jonathanmetzman
95f2bee47e
Upgrade to Python3.11 (#3229)
1. Change Docker images to use Python3
2. Change local scripts to support Python3
3. Fix installation of Chromium dependencies
4. Remove profiling code, the profiling package only supports up to
Python3.9
5. Recompile all protos and change some uworker serialization code that
has to work differently due to some changes in dependencies
6. Add many no-member pylint exemptions since pylint is now
misunderstanding proto members.
7. Change platforms for binary downloads during deploy
8. Upgrade packages that no longer work or have to be upgraded by
because of depdency/dependent upgrades
[Used everywhere]
a. grpcio
b. grpcio-tools
c. protobuf
[development]
d. parameterized
e. WebTest
[bots]
f. google-cloud-batch
g. google-cloud-core
h. google-cloud-datastore
i. google-cloud-logging
j. google-cloud-monitoring
k. google-cloud-ndb
l. google-cloud-storage
m. google-api-python-client
n. google-auth
o. google-api-core
[appengine]
p. cryptography
q. firebase-admin
r. PyJWT

9. Remove no longer used pip packages:
a. twisted
b. lxml
2023-07-24 14:31:45 -04:00
jonathanmetzman
d851e1081a
Remove mock package. (#3225)
It's now shipped with Python.
2023-07-16 10:49:55 -04:00
jonathanmetzman
bcf029094c
Delete future package (#3224)
It's a Python2->Python3 helper package and is no longer used.
2023-07-16 09:53:01 -04:00
jonathanmetzman
159106ef22
Downgrade grpcio to a version with binary builds (#3125) 2023-06-05 13:27:34 -04:00
jonathanmetzman
57dd7b5116
[NFC][six] Get rid of six (#3017)
Python2 isn't supported anymore.
2023-04-27 17:51:25 -04:00
Holly Gong
4af2b87e3f
Update pipenv version (#2982)
Update pipenv version to fix [issue
2981](https://github.com/google/clusterfuzz/issues/2981)

---------

Co-authored-by: Holly Gong <gongh@google.com>
2023-03-30 04:33:17 +00:00
Oliver Chang
fb88290102
Pin all vendored dependencies. (#2573)
* Pin all vendored dependencies.

Use a Pipfile to generate the requirements.txt to vendor.

For App Engine only dependencies, we use "dev-packages" as a hack to
make sure that version resolution always works and doesn't introduce
conflicts.

* fixes
2022-03-15 14:22:33 +11:00
Oliver Chang
4f8020c4c7
Restructure ClusterFuzz to be a proper package. (#2383)
Move most imports into an `clusterfuzz._internal` dir, and
change internal imports to be of the form: `from clusterfuzz._internal.base.* import ` etc.

This avoids a lot of global import namespace pollution, and makes our
libClusterFuzz setup much less hacky.

Actual changes:
- Rename most of "src/python" to "src/clusterfuzz/_internal".
- Keep "src/python/bot/startup" to avoid issues with existing startup
  scripts.
- Move "protos" to "src/clusterfuzz/_internal" as well.
- Convert all imports to be relative from clusterfuzz._internal.
- Use isort for import ordering, remove our own implementation for
  checking of ordering during lint.
- Temporarily add some lint exclusion rules, as there were quite a few
  that were failing.
- Relax line length rules for test files.
- Add a license check exclusion for process_state.proto, since it has a
  difference license from what we expect.

Tests before deploying:
- [x] stage on GCE bot
- [x] deploy to App Engine staging
- [x] test pip package 

Fixes #2192.
2021-07-26 14:42:30 +10:00
Abhishek Arya
5b54b40250
Fix some flaky tests. (#2347)
* Reenable incorrectly marked flaky tests.

* Try ulimit fix.

* Another try.

* try pyfakefs upgrade.

* Fix another test failure.

* Try upgrading grpcio
2021-05-21 12:48:07 -07:00
Oliver Chang
2b0e8a93f8
Support Python 3.9 for development. (#2317)
- Remove tensorflow from Pipfile as it repeatedly causes issues when a
  new Python version needs to be supported. It's not required for the
  majority of ClusterFuzz devs and most things run fine without it.
- Upgrade grpcio.
2021-04-27 10:37:42 +10:00
Oliver Chang
2a87ad725f
Upgrade protobuf. (#2266)
Something changed/broke:

AttributeError
module 'google.protobuf.descriptor' has no attribute
'_internal_create_key'
2021-02-26 11:37:00 +11:00
jonathanmetzman
daf8b00331
Fix failing unittests (#2247)
Fix unittests failing on HEAD because of a bug in pyfakefs.
Since all of these tests used fakefs, I tried upgrading it, which seemed to work.
Also upgraded the pipenv.lock file.
Fixes #2246
2021-02-18 18:24:09 +00:00
Oliver Chang
59de121ad4
Relax Python 3.7 requirement for local development. (#2149)
Allow any Python 3 local dev environment as long as it's >=3.7.

For deployment, add a check for 3.7 to ensure it can only occur from
there.
2020-11-20 10:44:58 +11:00
Oliver Chang
e28e851247
Add twine as a dev dependency. (#2123)
Twine is used for pip package uploading.

Also update the README.md slightly for libClusterFuzz.
2020-11-03 10:50:48 +11:00
Oliver Chang
20a4de8c85
Remove some dependencies for libClusterFuzz. (#2095)
* Remove some dependencies for libClusterFuzz.

- Move selenium to Pipfile.
- Move python-dateutil to appengine requirements.
- Remove hyperlink pin.
- Remove pytz.
- Remove configparser. This was a Python 2 backport of a Python 3
  module.
- Remove peach, antlr dependencies for Pip package.
- Also some import fixes for the pip package.

* remove debug print
2020-10-20 08:41:38 +11:00
Abhishek Arya
7f22aa1582
Revert "Upgrade TensorFlow from 2.3.0 to 2.3.1. (#2057)" (#2059)
This reverts commit 0a453ead25e12c63192f020d97f1be8e5cb4fb12.
2020-09-30 21:31:51 -07:00
Max Moroz
0a453ead25
Upgrade TensorFlow from 2.3.0 to 2.3.1. (#2057) 2020-09-30 17:16:56 -07:00
Max Moroz
59b844d977
Bump TensorFlow to a non-RC 2.3.0 version (#1540). (#1928) 2020-07-27 14:04:51 -07:00
Max Moroz
6afbbe57d7
Bump TensorFlow to 2.3.0rc2 (#1540). (#1921) 2020-07-24 10:19:16 -07:00
Oliver Chang
e370109a47
Add Python 3.7 requirement back to Pipfile. (#1916)
Fixes #1902.
2020-07-21 16:25:45 +10:00
Abhishek Arya
7650439c20
Remove python 2 requirements install from docker images. (#1836) 2020-06-18 17:34:39 -07:00
Abhishek Arya
09ec52138e
Revert "Build psutil in deployment, not use Pipenv. (#1773)" (#1774)
This reverts commit 6fb7c0d959fe3c77f9efd9dcf82e069c4f6eb5d4.
2020-05-12 16:39:07 -07:00
Abhishek Arya
6fb7c0d959
Build psutil in deployment, not use Pipenv. (#1773) 2020-05-12 15:54:44 -07:00
Abhishek Arya
93ca457ed0
Upgrade numpy and psutil for python 3.8 (#1772) 2020-05-12 14:15:35 -07:00
Oliver Chang
33854150d4
Upgrade dependencies for Python 3.8 support. (#1767)
* Upgrade dependencies for Python 3.8 support.

Tensorflow 2.x had some API changes. Used tf_upgrade_v2 for these.

* disable train tests
2020-05-07 14:25:30 +10:00
Abhishek Arya
c45f986ac8
Upgrade grpcio and grpcio-tools to 1.28.1 (#1751) 2020-04-27 09:45:37 -07:00
Oliver Chang
68acd63a4b
Upgrade gRPC to fix encoding issue. (#1684)
First release that contains:
a04a928cf3

We upgrade conservatively for now to avoid any other issues that may
arise while we migrate from Python 2 -> 3.
2020-03-27 16:57:41 +11:00
Oliver Chang
723b8b6a5e
Simplify tensorflow Pipfile dependency. (#1638) 2020-03-23 11:47:42 +11:00
Oliver Chang
2ac4d389fb
Remove some Python 3 dependencies. (#1612)
Some of these seem to be unused.
2020-03-19 09:11:38 +11:00
Max Moroz
32a646ce7f
Bump TensorFlow to 1.15.2 (a long term release), follow-up #1541. (#1548)
* Bump TensorFlow to 1.15.2 (a long term release), follow-up #1541.

* rebase
2020-03-16 08:18:50 -07:00
Abhishek Arya
c228d49f8a
Upgrade psutil from 5.4.7 to 5.6.6 (#1575) 2020-03-13 12:35:51 -07:00
Oliver Chang
6d220c3315
Set up CI for Python 3. (#1546) 2020-03-12 08:22:51 +11:00
Max Moroz
f259c08d3c
Fix TensorFlow dependency and ML RNN tests for Python3 (#1535). (#1541)
Besides the typical py2->3 problem in src/python/bot/fuzzers/ml/rnn/utils.py, another issue here is that tensorflow 1.8.0 is way too old and wasn't even built for Python3.7, and official tensorflow GCS bucket doesn't have it.

1.13.2 seems to be the first version built for Python3.7, and it's also not that new to break code compatibility. Should be acceptable in the meantime. After migration we'll update TF and its dependencies altogether (#1540).
2020-03-11 12:40:45 +11:00