Skip to main content
Solved

Error in deploying functions using 'requests' library through Github actions

  • February 10, 2025
  • 5 replies
  • 61 views

Forum|alt.badge.img+1

I am trying to deploy a function to CDF using the deploy-functions-oidc repo in Github. It works perfectly fine for other functions, but for functions using the “requests” library i get the following error during pre-commit: “Library stubs not installed for requests. Hint: “python3 -m pip install types-requests”. I have included both requests and types-requests in the requirement.txt file. Anyone experienced the same issue?

Best answer by Ivar Stangeby

Right, so - the type checker `mypy` is running sandboxed in the pre-commit, so it does not know about the types installed in your environment. To have `mypy` aware of `types-requests` you can add it as additional dependencies in the `.pre_commit_config.yaml`.

```
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy
        additional_dependencies: ['types-requests']
```

Let me know if this does not solve it for you, and I’d be happy to help further!

 

View original
Did this topic help you find an answer to your question?

5 replies

  • Practitioner
  • 22 replies
  • February 10, 2025

Hello, ​@Espen Ulset Nordsveen ! 

I’m trying to reproduce this issue on my end now. I’ve seen this before.
 


  • Practitioner
  • 22 replies
  • Answer
  • February 10, 2025

Right, so - the type checker `mypy` is running sandboxed in the pre-commit, so it does not know about the types installed in your environment. To have `mypy` aware of `types-requests` you can add it as additional dependencies in the `.pre_commit_config.yaml`.

```
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy
        additional_dependencies: ['types-requests']
```

Let me know if this does not solve it for you, and I’d be happy to help further!

 


Forum|alt.badge.img+1

Thanks ​@Ivar Stangeby ! That removed the requests issue, but introduced the following: “error: Cannot find implementation or library stub for module named "cognite.client.data_classes"  [import-not-found]”. Any ideas on where to go from here? I am using the Event data class


Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@Espen Ulset Nordsveen  have you included the cognite-sdk in the requirement.txt file?


Forum|alt.badge.img+1

@Mithila Jayalath  Yes. But I did not include it in the .pre-commit-config.yaml file. Now it works. Thanks!


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings