Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,10 @@ gravity_tasks = [
{"topic": "r/MachineLearning", "platform": "reddit"},
]

notification = {
"type": "email",
"address": "<your-email-address>",
"redirect_url": "https://app.macrocosmos.ai/",
}

response = client.gravity.CreateGravityTask(
gravity_tasks=gravity_tasks, name="My First Gravity Task", notification_requests=[notification]
gravity_tasks=gravity_tasks,
name="My First Gravity Task",
notification_requests=[{"type": "email"}]
)

# Print the gravity task ID
Expand All @@ -158,22 +154,17 @@ print(response)
```

### Build Dataset
If you do not want to wait 7-days for your data, you can request it earlier. Add a notification to get notified when the build is complete or you can monitor the status by calling `GetDataset()`. Once the dataset is built, the gravity task will be de-registered. Calling `CancelDataset()` will cancel a build in-progress or, if it's already complete, will purge the created dataset.
If you do not want to wait 7-days for your data, you can request it earlier. Once the dataset is built, you will receive a notification email to your Macrcocosmos sign-up address, and the gravity task will be de-registered. Calling `CancelDataset()` will cancel a build in-progress or, if it's already complete, will purge the created dataset.

```py
import macrocosmos as mc

client = mc.GravityClient(api_key="<your-api-key>", app_name="my_app")

notification = {
"type": "email",
"address": "<your-email-address>",
"redirect_url": "https://app.macrocosmos.ai/",
}

response = client.gravity.BuildDataset(
crawler_id="<your-crawler-id>", notification_requests=[notification]
)
crawler_id="<your-crawler-id>",
notification_requests=[{"type": "email"}]
)

# Print the dataset ID
print(response)
Expand Down
18 changes: 2 additions & 16 deletions examples/gravity_workflow_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,11 @@ async def create_new_task(self):
{"topic": self.reddit_subreddit, "platform": "reddit"},
]

# User info for notifications
notification = {
"type": "email",
"address": self.email,
"redirect_url": "https://app.macrocosmos.ai/",
}

# Create the task
response = await self.client.gravity.CreateGravityTask(
gravity_tasks=gravity_tasks,
name=self.task_name,
notification_requests=[notification],
notification_requests=[{"type": "email"}],
)

self.task_id = response.gravity_task_id
Expand Down Expand Up @@ -258,18 +251,11 @@ async def build_datasets(self, crawler_ids: Set[str]):

for crawler_id in crawler_ids:
try:
# Notification for dataset completion
notification = {
"type": "email",
"address": self.email,
"redirect_url": "https://app.macrocosmos.ai/gravity/tasks",
}

# Build dataset
response = await self.client.gravity.BuildDataset(
crawler_id=crawler_id,
max_rows=self.max_rows,
notification_requests=[notification],
notification_requests=[{"type": "email"}],
)

if response and response.dataset_id:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "macrocosmos"
version = "1.1.3"
version = "1.1.4"
description = "The official Python SDK for Macrocosmos"
readme = "README.md"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.