[−][src]Struct kaggle::client::KaggleApiClient
Client to interact with the kaggle api.
#Example
use kaggle::KaggleApiClient; let kaggle = KaggleApiClient::builder().build().unwrap();
Methods
impl KaggleApiClient
[src]
pub fn builder() -> KaggleApiClientBuilder
[src]
Convenience method to create a KaggleApiClientBuilder
pub fn download_dir(&self) -> &PathBuf
[src]
The directory where downloads are stored.
impl KaggleApiClient
[src]
pub fn get_user_and_identifier_slug<'a>(
&'a self,
id: &'a str
) -> Result<(&'a str, &'a str), KaggleError>
[src]
&'a self,
id: &'a str
) -> Result<(&'a str, &'a str), KaggleError>
Determine if a dataset string is valid, meaning it is in the format of {username}/{identifier-slug}
impl KaggleApiClient
[src]
pub async fn competitions_list<'_, '_>(
&'_ self,
competition: &'_ CompetitionsList
) -> Result<Vec<Competition>>
[src]
&'_ self,
competition: &'_ CompetitionsList
) -> Result<Vec<Competition>>
Returns a list of `Competition' instances.
pub async fn competition_download_leaderboard<'_>(
&'_ self,
id: impl AsRef<str>,
output: Option<PathBuf>
) -> Result<PathBuf>
[src]
&'_ self,
id: impl AsRef<str>,
output: Option<PathBuf>
) -> Result<PathBuf>
Download competition leaderboard as zip file, as zip containing a csv of
KaggleApiClient::competition_view_leaderboard
.
If [output
] is a directory then the destination of the leaderboard zip
file will be <output>/<id>-leaderboard.zip
.
If [output
] is a file then this is the destination of downloaded
leaderboard zip.
If [output
] is None
, then the destination is
<self.download_dir>/<id>-leaderboard.zip
Example
use kaggle::query::CompetitionSortBy; use kaggle::request::CompetitionsList; use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .competitions_list( &CompetitionsList::default() .sort_by(CompetitionSortBy::RecentlyCreated) .search("health"), ) .await?; Ok(()) }
pub async fn competition_view_leaderboard<'_>(
&'_ self,
id: impl AsRef<str>
) -> Result<LeaderBoard>
[src]
&'_ self,
id: impl AsRef<str>
) -> Result<LeaderBoard>
View a leaderboard based on a competition name
Example
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .competition_view_leaderboard("digit-recognizer") .await?; Ok(()) }
pub async fn competitions_data_download_file<'_>(
&'_ self,
id: impl AsRef<str>,
file_name: impl AsRef<str>,
target: Option<PathBuf>
) -> Result<PathBuf>
[src]
&'_ self,
id: impl AsRef<str>,
file_name: impl AsRef<str>,
target: Option<PathBuf>
) -> Result<PathBuf>
Download a competition data file to a designated location, or to download location. Returns the location of the zip file download.
Errors
This will fail if the authorized user has not yet accepted the competition's rules.
Example
Download file train.csv
from competition
3d-object-detection-for-autonomous-vehicles
as zipfile to
<download-dir>/train.csv.zip
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .competitions_data_download_file( "3d-object-detection-for-autonomous-vehicles", "train.csv", None, ) .await?; Ok(()) }
pub async fn competitions_data_download_all_files<'_>(
&'_ self,
id: impl AsRef<str>,
target: Option<PathBuf>
) -> Result<PathBuf>
[src]
&'_ self,
id: impl AsRef<str>,
target: Option<PathBuf>
) -> Result<PathBuf>
Downloads all competition files and returns the location of the zip file download.
Errors
This will fail if the authorized user has not yet accepted the competition's rules.
Example
Download all files from competition
m5-forecasting-accuracy
as zipfile to
<download-dir>/m5-forecasting-accuracy.zip
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .competitions_data_download_all_files( "m5-forecasting-accuracy", None, ) .await?; Ok(()) }
pub async fn competitions_data_list_files<'_>(
&'_ self,
id: impl AsRef<str>
) -> Result<Vec<File>>
[src]
&'_ self,
id: impl AsRef<str>
) -> Result<Vec<File>>
List all data files for a competition
Example
Overview of all files in the m5-forecasting-accuracy
competition
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .competitions_data_list_files( "m5-forecasting-accuracy", ) .await?; Ok(()) }
pub async fn competitions_submissions_list<'_>(
&'_ self,
id: impl AsRef<str>,
page: usize
) -> Result<Vec<Submission>>
[src]
&'_ self,
id: impl AsRef<str>,
page: usize
) -> Result<Vec<Submission>>
Get the list submissions for a particular competition
pub async fn competitions_submissions_submit<'_>(
&'_ self,
id: impl AsRef<str>,
blob_file_tokens: impl ToString,
submission_description: impl ToString
) -> Result<SubmitResult>
[src]
&'_ self,
id: impl AsRef<str>,
blob_file_tokens: impl ToString,
submission_description: impl ToString
) -> Result<SubmitResult>
Submit to competition.
pub async fn competition_submit<'_>(
&'_ self,
file: impl AsRef<Path>,
competition: impl AsRef<str>,
message: impl ToString
) -> Result<SubmitResult>
[src]
&'_ self,
file: impl AsRef<Path>,
competition: impl AsRef<str>,
message: impl ToString
) -> Result<SubmitResult>
Submit a competition.
pub async fn dataset_create_new<'_>(
&'_ self,
new_dataset: DatasetNew
) -> Result<DatasetNewResponse>
[src]
&'_ self,
new_dataset: DatasetNew
) -> Result<DatasetNewResponse>
Create a new dataset meaning the same as creating a version but with extra metadata like license and user/owner.
This will upload any referenced resources in the metadata resources. This will fail on kaggle if the metadata contains no resources to upload.
Example
Create a new kaggle dataset based on the ./dataset-metadata.json
{
"title": "My Awesome dataset",
"id": "mattsse/my-awesome-dataset",
"licenses": [
{
"name": "CC0-1.0"
}
],
"resources": [
{
"path": "LICENSE",
"description": "This is the license"
}
]
}
use kaggle::models::DatasetNew; use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .dataset_create_new(DatasetNew::with_metadata_file(".").await?) .await?; Ok(()) }
pub async fn dataset_create_version<'_>(
&'_ self,
folder: impl AsRef<Path>,
version_notes: impl ToString,
convert_to_csv: bool,
delete_old_versions: bool,
archive_mode: ArchiveMode
) -> Result<DatasetNewVersionResponse>
[src]
&'_ self,
folder: impl AsRef<Path>,
version_notes: impl ToString,
convert_to_csv: bool,
delete_old_versions: bool,
archive_mode: ArchiveMode
) -> Result<DatasetNewVersionResponse>
Create a new dataset version
pub async fn datasets_create_version<'_, '_, '_>(
&'_ self,
name: &'_ str,
dataset_req: &'_ DatasetNewVersionRequest
) -> Result<DatasetNewVersionResponse>
[src]
&'_ self,
name: &'_ str,
dataset_req: &'_ DatasetNewVersionRequest
) -> Result<DatasetNewVersionResponse>
Create a new dataset version
pub async fn datasets_create_version_by_id<'_, '_>(
&'_ self,
id: i32,
dataset_req: &'_ DatasetNewVersionRequest
) -> Result<DatasetNewVersionResponse>
[src]
&'_ self,
id: i32,
dataset_req: &'_ DatasetNewVersionRequest
) -> Result<DatasetNewVersionResponse>
Create a new dataset version by id
pub async fn dataset_download_all_files<'_, '_>(
&'_ self,
name: impl AsRef<str>,
path: Option<PathBuf>,
dataset_version_number: Option<&'_ str>
) -> Result<PathBuf>
[src]
&'_ self,
name: impl AsRef<str>,
path: Option<PathBuf>,
dataset_version_number: Option<&'_ str>
) -> Result<PathBuf>
Download all files of a dataset.
Example
Download the newest version of the whole unanimad/dataisbeautiful
dataset as zip file into
<download-dir>/datasets/unanimad/dataisbeautiful.zip
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .dataset_download_all_files("unanimad/dataisbeautiful", None, None) .await?; Ok(()) }
pub async fn dataset_download_file<'_, '_>(
&'_ self,
name: impl AsRef<str>,
file_name: impl AsRef<str>,
folder: Option<PathBuf>,
dataset_version_number: Option<&'_ str>
) -> Result<PathBuf>
[src]
&'_ self,
name: impl AsRef<str>,
file_name: impl AsRef<str>,
folder: Option<PathBuf>,
dataset_version_number: Option<&'_ str>
) -> Result<PathBuf>
Download a single file for a dataset.
pub async fn datasets_list<'_, '_>(
&'_ self,
list: &'_ DatasetsList
) -> Result<Vec<Dataset>>
[src]
&'_ self,
list: &'_ DatasetsList
) -> Result<Vec<Dataset>>
List datasets
Example
use kaggle::request::DatasetsList; use kaggle::KaggleApiClient; use kaggle::query::SortBy; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .datasets_list( &DatasetsList::default() .sort_by(SortBy::ViewCount) .search("health"), ) .await?; Ok(()) }
pub async fn datasets_list_files<'_>(
&'_ self,
name: impl AsRef<str>
) -> Result<ListFilesResult>
[src]
&'_ self,
name: impl AsRef<str>
) -> Result<ListFilesResult>
List all files for a dataset.
If the [name
] is not a combination of
<user-name-slug>/<dataset-name-slug>
but only a single slug, the
client request to list all the files for the authorized user's dataset
with that name <client-auth-username>/<name>
.
Example
List all files for a dataset provided by another user.
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .datasets_list_files("allen-institute-for-ai/CORD-19-research-challenge") .await?; Ok(()) }
Example
List all files for your own dataset.
use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .datasets_list_files("my-awesome-dataset") .await?; Ok(()) }
pub async fn datasets_status<'_>(
&'_ self,
name: impl AsRef<str>
) -> Result<Option<Value>>
[src]
&'_ self,
name: impl AsRef<str>
) -> Result<Option<Value>>
Get dataset creation status.
pub async fn datasets_upload_file<'_>(
&'_ self,
file_name: impl ToString,
content_length: u64,
last_modified_date_utc: Duration
) -> Result<FileUploadInfo>
[src]
&'_ self,
file_name: impl ToString,
content_length: u64,
last_modified_date_utc: Duration
) -> Result<FileUploadInfo>
Get URL and token to start uploading a data file.
pub async fn datasets_view<'_>(
&'_ self,
name: impl AsRef<str>
) -> Result<Dataset>
[src]
&'_ self,
name: impl AsRef<str>
) -> Result<Dataset>
Show details about a dataset.
pub async fn kernels_output<'_>(
&'_ self,
name: impl AsRef<str>,
path: Option<PathBuf>
) -> Result<Vec<PathBuf>>
[src]
&'_ self,
name: impl AsRef<str>,
path: Option<PathBuf>
) -> Result<Vec<PathBuf>>
Retrieve output for a specified kernel.
pub async fn kernel_output<'_>(
&'_ self,
name: impl AsRef<str>
) -> Result<KernelOutput>
[src]
&'_ self,
name: impl AsRef<str>
) -> Result<KernelOutput>
RDownload the latest output from a kernel
pub async fn kernel_pull<'_>(
&'_ self,
name: impl AsRef<str>
) -> Result<KernelPullResponse>
[src]
&'_ self,
name: impl AsRef<str>
) -> Result<KernelPullResponse>
Pull the latest code from a kernel.
pub async fn kernels_pull<'_>(
&'_ self,
pull: KernelPullRequest
) -> Result<(PathBuf, Option<PathBuf>)>
[src]
&'_ self,
pull: KernelPullRequest
) -> Result<(PathBuf, Option<PathBuf>)>
Pull a kernel, including a metadata file (if metadata is True) and associated files to a specified path.
pub async fn kernels_push<'_>(
&'_ self,
folder: impl AsRef<Path>
) -> Result<KernelPushResponse>
[src]
&'_ self,
folder: impl AsRef<Path>
) -> Result<KernelPushResponse>
read the metadata file and kernel files from a notebook, validate both, and use Kernel API to push to Kaggle if all is valid.
pub async fn kernel_push<'_, '_>(
&'_ self,
kernel_push_request: &'_ KernelPushRequest
) -> Result<KernelPushResponse>
[src]
&'_ self,
kernel_push_request: &'_ KernelPushRequest
) -> Result<KernelPushResponse>
Push a new kernel version. Can be used to create a new kernel and update an existing one.
pub async fn kernel_status<'_>(&'_ self, name: impl AsRef<str>) -> Result<Value>
[src]
Get the status of a kernel.
pub async fn kernels_list<'_, '_>(
&'_ self,
kernel_list: &'_ KernelsList
) -> Result<Vec<Kernel>>
[src]
&'_ self,
kernel_list: &'_ KernelsList
) -> Result<Vec<Kernel>>
List kernels based on a set of search criteria.
Example
use kaggle::request::KernelsList; use kaggle::KaggleApiClient; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let kaggle = KaggleApiClient::builder().build()?; let resp = kaggle .kernels_list(&KernelsList::default().search("health")) .await?; Ok(()) }
pub async fn metadata_get<'_>(
&'_ self,
name: impl AsRef<str>
) -> Result<DatasetMetadata>
[src]
&'_ self,
name: impl AsRef<str>
) -> Result<DatasetMetadata>
Get the metadata for a dataset.
pub async fn dataset_metadata_update<'_>(
&'_ self,
name: impl AsRef<str>,
path: Option<PathBuf>
) -> Result<Value>
[src]
&'_ self,
name: impl AsRef<str>,
path: Option<PathBuf>
) -> Result<Value>
Update the metadata for a dataset
pub async fn metadata_post<'_, '_>(
&'_ self,
name: impl AsRef<str>,
settings: &'_ DatasetUpdateSettingsRequest
) -> Result<Value>
[src]
&'_ self,
name: impl AsRef<str>,
settings: &'_ DatasetUpdateSettingsRequest
) -> Result<Value>
Trait Implementations
impl Clone for KaggleApiClient
[src]
fn clone(&self) -> KaggleApiClient
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for KaggleApiClient
impl !Send for KaggleApiClient
impl !Sync for KaggleApiClient
impl Unpin for KaggleApiClient
impl !UnwindSafe for KaggleApiClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,