Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def submit_result(self, submit_msg='KakaoAutoML'):
"""
Submit result to kaggle and wait for getting the result.
"""
logger.info('kaggle.submit_result: initialization')
api_client = KaggleApi()
api_client.authenticate()
submissions = api_client.competitionSubmissions(KaggleSubmission.CNAME)
last_idx = submissions[0].ref if len(submissions) > 0 else -1
# submit
logger.info('kaggle.submit_result: trying to submit @ %s' % self.get_filepath())
submit_result = api_client.competitionSubmit(self.get_filepath(), submit_msg, KaggleSubmission.CNAME)
logger.info('kaggle.submit_result: submitted!')
# wait for the updated LB
wait_interval = 10 # in seconds
for _ in range(60 // wait_interval * 5):
submissions = api_client.competitionSubmissions(KaggleSubmission.CNAME)
if len(submissions) == 0:
continue
if submissions[0].status == 'complete' and submissions[0].ref != last_idx:
def retrieve_dataset(input_dir):
input_dir = Path(input_dir)
zip_files = ["train.zip", "test.zip"]
if not input_dir.exists():
os.makedirs(input_dir)
api = KaggleApi(ApiClient())
api.authenticate()
api.competition_download_files("human-protein-atlas-image-classification",
input_dir, force=True, quiet=False)
print("Extracting files...")
for file in zip_files:
pth = input_dir / file.split(".")[0]
if not pth.exists():
os.mkdir(pth)
zip_ref = zipfile.ZipFile(input_dir / file, 'r')
zip_ref.extractall(pth)
zip_ref.close()
os.remove(input_dir / file)
print("Dataset downloaded!")
else:
print("Dataset already present in input dir, skipping...")
return input_dir
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
from __future__ import absolute_import
from kaggle.api.kaggle_api_extended import KaggleApi
from kaggle.api_client import ApiClient
api = KaggleApi(ApiClient())
api.authenticate()
from ..models.license import License
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from ..rest import ApiException
import six
from slugify import slugify
from tqdm import tqdm
try:
unicode # Python 2
except NameError:
unicode = str # Python 3
class KaggleApi(KaggleApi):
__version__ = '1.5.6'
CONFIG_NAME_PROXY = 'proxy'
CONFIG_NAME_COMPETITION = 'competition'
CONFIG_NAME_PATH = 'path'
CONFIG_NAME_USER = 'username'
CONFIG_NAME_KEY = 'key'
CONFIG_NAME_SSL_CA_CERT = 'ssl_ca_cert'
HEADER_API_VERSION = 'X-Kaggle-ApiVersion'
DATASET_METADATA_FILE = 'dataset-metadata.json'
OLD_DATASET_METADATA_FILE = 'datapackage.json'
KERNEL_METADATA_FILE = 'kernel-metadata.json'
config_dir = os.environ.get('KAGGLE_CONFIG_DIR') or os.path.join(
expanduser('~'), '.kaggle')