0

Merge pull request #218 from mendableai/nsc/python-sdk-waiting-fixes

[sdk] Fixes waiting status not being present on check status
This commit is contained in:
Nicolas 2024-05-31 11:54:27 -07:00 committed by GitHub
commit 03ba4a9fa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 26 additions and 5 deletions

View File

@ -132,7 +132,7 @@ export async function supaAuthenticateUser(
const retryDate = new Date(Date.now() + rateLimiterRes.msBeforeNext); const retryDate = new Date(Date.now() + rateLimiterRes.msBeforeNext);
return { return {
success: false, success: false,
error: `Rate limit exceeded. Consumed points: ${rateLimiterRes.consumedPoints}, Remaining points: ${rateLimiterRes.remainingPoints}. Please retry after ${secs}s, resets at ${retryDate}`, error: `Rate limit exceeded. Consumed points: ${rateLimiterRes.consumedPoints}, Remaining points: ${rateLimiterRes.remainingPoints}. Upgrade your plan at https://firecrawl.dev/pricing for increased rate limits or please retry after ${secs}s, resets at ${retryDate}`,
status: 429, status: 429,
}; };
} }

View File

@ -273,7 +273,7 @@ class FirecrawlApp:
return status_data['data'] return status_data['data']
else: else:
raise Exception('Crawl job completed but no data was returned') raise Exception('Crawl job completed but no data was returned')
elif status_data['status'] in ['active', 'paused', 'pending', 'queued']: elif status_data['status'] in ['active', 'paused', 'pending', 'queued', 'waiting']:
timeout=max(timeout,2) timeout=max(timeout,2)
time.sleep(timeout) # Wait for the specified timeout before checking again time.sleep(timeout) # Wait for the specified timeout before checking again
else: else:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -273,7 +273,7 @@ class FirecrawlApp:
return status_data['data'] return status_data['data']
else: else:
raise Exception('Crawl job completed but no data was returned') raise Exception('Crawl job completed but no data was returned')
elif status_data['status'] in ['active', 'paused', 'pending', 'queued']: elif status_data['status'] in ['active', 'paused', 'pending', 'queued', 'waiting']:
timeout=max(timeout,2) timeout=max(timeout,2)
time.sleep(timeout) # Wait for the specified timeout before checking again time.sleep(timeout) # Wait for the specified timeout before checking again
else: else:

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: firecrawl-py Name: firecrawl-py
Version: 0.0.11 Version: 0.0.12
Summary: Python SDK for Firecrawl API Summary: Python SDK for Firecrawl API
Home-page: https://github.com/mendableai/firecrawl Home-page: https://github.com/mendableai/firecrawl
Author: Mendable.ai Author: Mendable.ai
@ -151,6 +151,25 @@ status = app.check_crawl_status(job_id)
The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message. The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message.
## Running the Tests with Pytest
To ensure the functionality of the Firecrawl Python SDK, we have included end-to-end tests using `pytest`. These tests cover various aspects of the SDK, including URL scraping, web searching, and website crawling.
### Running the Tests
To run the tests, execute the following commands:
Install pytest:
```bash
pip install pytest
```
Run:
```bash
pytest firecrawl/__tests__/e2e_withAuth/test.py
```
## Contributing ## Contributing
Contributions to the Firecrawl Python SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository. Contributions to the Firecrawl Python SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

View File

@ -1 +1,3 @@
requests requests
pytest
python-dotenv

View File

@ -7,7 +7,7 @@ long_description_content = (this_directory / "README.md").read_text()
setup( setup(
name="firecrawl-py", name="firecrawl-py",
version="0.0.11", version="0.0.12",
url="https://github.com/mendableai/firecrawl", url="https://github.com/mendableai/firecrawl",
author="Mendable.ai", author="Mendable.ai",
author_email="nick@mendable.ai", author_email="nick@mendable.ai",