mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 09:48:44 +00:00
wip
This commit is contained in:
1 parent
0c49c665b2
commit
efd873b8d0
4 files changed
+135
-3
No files matched your search
@@ -13,7 +13,6 @@ const RUN_VERSION : &str = "0.0.1";
|
||||
/// - request #6 - patch run after image upload
|
||||
/// Gotta go fast?
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
|
||||
pub struct RunObject {
|
||||
/// The primary ID of the run.
|
||||
/// This won't exist until we post it to the server.
|
||||
|
||||
+54
@@ -20,6 +20,60 @@ curl 'https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects/79795b32-e44d-4333
|
||||
-H 'TE: trailers' \
|
||||
--data-raw '{"object":{"metadata":{"version":"0.0.1","createdAt":1765756772176,"updatedAt":1765756773647,"useAdvancedEditing":false,"draftMode":false,"nodes":{"bc17252b-811e-49d7-be3e-b7c538df9d30":{"id":"bc17252b-811e-49d7-be3e-b7c538df9d30","type":"input","parentId":null,"source":{"type":"image","image_url":"https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg"},"createdAt":1765756773647},"82f6b488-8afe-4311-9022-80ad5789ad92":{"id":"82f6b488-8afe-4311-9022-80ad5789ad92","type":"pano","parentId":"bc17252b-811e-49d7-be3e-b7c538df9d30","source":{"type":"generate_world","world_id":"pending","status":"pending"},"createdAt":1765756773647},"f08ec501-601c-47c6-a104-402d1820b8f0":{"id":"f08ec501-601c-47c6-a104-402d1820b8f0","type":"world","parentId":"82f6b488-8afe-4311-9022-80ad5789ad92","source":{"type":"generate_world","world_id":"pending","posed_cubemaps_url":"","minimap_url":"","minimap_metadata":"","status":"pending"},"createdAt":1765756773647}}}},"update_mask":["metadata"]}'
|
||||
|
||||
Request Body:
|
||||
|
||||
{
|
||||
"object": {
|
||||
"metadata": {
|
||||
"version": "0.0.1",
|
||||
"createdAt": 1765756772176,
|
||||
"updatedAt": 1765756773647,
|
||||
"useAdvancedEditing": false,
|
||||
"draftMode": false,
|
||||
"nodes": {
|
||||
"bc17252b-811e-49d7-be3e-b7c538df9d30": {
|
||||
"id": "bc17252b-811e-49d7-be3e-b7c538df9d30",
|
||||
"type": "input",
|
||||
"parentId": null,
|
||||
"source": {
|
||||
"type": "image",
|
||||
"image_url": "https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg"
|
||||
},
|
||||
"createdAt": 1765756773647
|
||||
},
|
||||
"82f6b488-8afe-4311-9022-80ad5789ad92": {
|
||||
"id": "82f6b488-8afe-4311-9022-80ad5789ad92",
|
||||
"type": "pano",
|
||||
"parentId": "bc17252b-811e-49d7-be3e-b7c538df9d30",
|
||||
"source": {
|
||||
"type": "generate_world",
|
||||
"world_id": "pending",
|
||||
"status": "pending"
|
||||
},
|
||||
"createdAt": 1765756773647
|
||||
},
|
||||
"f08ec501-601c-47c6-a104-402d1820b8f0": {
|
||||
"id": "f08ec501-601c-47c6-a104-402d1820b8f0",
|
||||
"type": "world",
|
||||
"parentId": "82f6b488-8afe-4311-9022-80ad5789ad92",
|
||||
"source": {
|
||||
"type": "generate_world",
|
||||
"world_id": "pending",
|
||||
"posed_cubemaps_url": "",
|
||||
"minimap_url": "",
|
||||
"minimap_metadata": "",
|
||||
"status": "pending"
|
||||
},
|
||||
"createdAt": 1765756773647
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"update_mask": [
|
||||
"metadata"
|
||||
]
|
||||
}
|
||||
|
||||
Response:
|
||||
|
||||
{"context":null,"id":"79795b32-e44d-4333-bac1-05b2c9a3ea12","display_name":null,"owner_id":"CArJJ2PQFFd8l2Rf8uptZhl86d33","status":"CREATED","created_at":1765756772,"updated_at":1765756773,"object_uri":null,"mime_type":"application/run+json","metadata":{"version":"0.0.1","createdAt":1765756772176,"updatedAt":1765756773647,"useAdvancedEditing":false,"draftMode":false,"nodes":{"bc17252b-811e-49d7-be3e-b7c538df9d30":{"id":"bc17252b-811e-49d7-be3e-b7c538df9d30","type":"input","parentId":null,"source":{"type":"image","image_url":"https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg"},"createdAt":1765756773647},"82f6b488-8afe-4311-9022-80ad5789ad92":{"id":"82f6b488-8afe-4311-9022-80ad5789ad92","type":"pano","parentId":"bc17252b-811e-49d7-be3e-b7c538df9d30","source":{"type":"generate_world","world_id":"pending","status":"pending"},"createdAt":1765756773647},"f08ec501-601c-47c6-a104-402d1820b8f0":{"id":"f08ec501-601c-47c6-a104-402d1820b8f0","type":"world","parentId":"82f6b488-8afe-4311-9022-80ad5789ad92","source":{"type":"generate_world","world_id":"pending","posed_cubemaps_url":"","minimap_url":"","minimap_metadata":"","status":"pending"},"createdAt":1765756773647}}}}
|
||||
|
||||
+6
@@ -40,6 +40,7 @@ pub struct FinalizeObjectImageUploadArgs<'a> {
|
||||
|
||||
pub struct FinalizeObjectImageUploadResponse {
|
||||
pub object_url: String,
|
||||
pub updated_at: u64,
|
||||
}
|
||||
|
||||
/// Marble Image-to-World
|
||||
@@ -114,6 +115,7 @@ pub async fn finalize_object_image_upload(args: FinalizeObjectImageUploadArgs<'_
|
||||
|
||||
Ok(FinalizeObjectImageUploadResponse {
|
||||
object_url: response.object_uri,
|
||||
updated_at: response.updated_at,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -121,6 +123,10 @@ pub async fn finalize_object_image_upload(args: FinalizeObjectImageUploadArgs<'_
|
||||
struct RawResponse {
|
||||
/// eg. "https://cdn.marble.worldlabs.ai/object/foo-bar-baz-bin/asset.jpg"
|
||||
pub object_uri: String,
|
||||
|
||||
/// Seconds-resolution timestamp.
|
||||
/// eg. `1765745771`
|
||||
pub updated_at: u64,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+75
-2
@@ -154,7 +154,7 @@ struct ObjectMetadata {
|
||||
pub draft_mode: bool,
|
||||
|
||||
/// Polymorphic set of ID-to-object mappings.
|
||||
pub nodes: HashMap<String, Value>,
|
||||
pub nodes: HashMap<String, NodeValue>,
|
||||
}
|
||||
|
||||
impl Default for RawRequest {
|
||||
@@ -177,6 +177,68 @@ impl Default for RawRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl RawRequest {
|
||||
pub fn add_image_input_node(&mut self, node: ImageInputNode) {
|
||||
self.object.metadata.nodes.insert(node.id.clone(), NodeValue::ImageInput(node));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(untagged)]
|
||||
//#[serde(tag = "type", content = "value")]
|
||||
enum NodeValue {
|
||||
ImageInput(ImageInputNode),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
struct ImageInputNode {
|
||||
pub id: String,
|
||||
pub r#type: TypeInput,
|
||||
#[serde(rename = "parentId")]
|
||||
pub parent_id: Option<String>,
|
||||
pub source: ImageInputNodeSource,
|
||||
#[serde(rename = "createdAt")]
|
||||
pub created_at: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
struct ImageInputNodeSource {
|
||||
pub r#type: TypeInput,
|
||||
pub image_url: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
enum TypeInput {
|
||||
#[serde(rename = "input")]
|
||||
#[default]
|
||||
Input
|
||||
}
|
||||
|
||||
//impl Default for ImageInputNode {
|
||||
// fn default() -> Self {
|
||||
// Self {
|
||||
// id: "".to_string(),
|
||||
// r#type: TypeInput::Input,
|
||||
// parent_id: None,
|
||||
// source: ImageInputNodeSource {
|
||||
// r#type: TypeInput::Input,
|
||||
// image_url: "".to_string()
|
||||
// },
|
||||
// created_at: 0,
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
impl ImageInputNode {
|
||||
pub fn with_id(id: String) -> Self{
|
||||
Self {
|
||||
id,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct RawResponse {
|
||||
pub id: String,
|
||||
@@ -184,7 +246,7 @@ struct RawResponse {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::requests::objects::update_run_object_with_upload::RawRequest;
|
||||
use crate::api::requests::objects::update_run_object_with_upload::{ImageInputNode, RawRequest};
|
||||
|
||||
#[test]
|
||||
fn request_default() {
|
||||
@@ -193,4 +255,15 @@ mod tests {
|
||||
assert!(request.object.metadata.created_at > 10000);
|
||||
assert!(request.object.metadata.updated_at > 10000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json() {
|
||||
let mut request = RawRequest::default();
|
||||
|
||||
request.add_image_input_node(ImageInputNode::with_id("foo_id".to_string()));
|
||||
|
||||
let json = serde_json::to_string_pretty(&request).unwrap();
|
||||
println!("{}", json);
|
||||
assert_eq!(json, r#"{"type":"abcxyz_image_input_id","value":"image_input_id"}"#);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user