Skip to content

Commit 7083bcf

Browse files
committed
chore: work with schemav2 but still write files for debugging
1 parent 63f2ed3 commit 7083bcf

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/agent_toolkit/forestadmin/agent_toolkit/agent.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ async def _start(self):
200200
ForestLogger.log("debug", "Starting agent")
201201

202202
if self.options["skip_schema_update"] is False:
203-
try:
204-
api_map = await SchemaEmitter.get_serialized_schema(
205-
self.options, await self.customizer.get_datasource(), self.meta
206-
)
207-
await ForestHttpApi.send_schema(self.options, api_map)
208-
except Exception:
209-
ForestLogger.log("exception", "Error generating/sending forest schema V1")
203+
# try:
204+
# api_map = await SchemaEmitter.get_serialized_schema(
205+
# self.options, await self.customizer.get_datasource(), self.meta
206+
# )
207+
# await ForestHttpApi.send_schema(self.options, api_map)
208+
# except Exception:
209+
# ForestLogger.log("exception", "Error generating/sending forest schema V1")
210210

211211
try:
212212
api_map = await SchemaEmitterV2.get_serialized_schema(

src/agent_toolkit/forestadmin/agent_toolkit/utils/forest_schema/emitter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ async def get_serialized_schema(
7878
)
7979
raise
8080

81-
return cls.serialize(collections_schema, meta)
81+
serialized = cls.serialize(collections_schema, meta)
82+
with open(f'{options["schema_path"].split(".json")[0]}_json_api.json', "w") as fout:
83+
json.dump(serialized, fout, indent=4)
84+
return serialized
8285

8386
@staticmethod
8487
async def generate(

src/agent_toolkit/forestadmin/agent_toolkit/utils/http.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ async def send_schema_v2(cls, options: HttpOptions, schema: ForestSchemaV2) -> b
170170
{"forest-secret-key": options["env_secret"], "content-type": "application/json"},
171171
options["verify_ssl"],
172172
)
173-
# TODO: this dump is only to compare schema during poc
174-
with open(options["schema_path"], "w") as fout:
175-
json.dump(ret, fout, indent=4)
173+
pass
174+
# TODO: remove file writing just after this dump is only to compare schema during poc
175+
if ret:
176+
with open(options["schema_path"], "w") as fout:
177+
json.dump(ret["schemaV1"], fout, indent=4)
178+
179+
with open(f'{options["schema_path"].split(".json")[0]}_json_api.json', "w") as fout:
180+
json.dump(ret["schemaV1JSONAPI"], fout, indent=4)

0 commit comments

Comments
 (0)