id
int64
1
6.07M
name
stringlengths
1
295
code
stringlengths
12
426k
language
stringclasses
1 value
source_file
stringlengths
5
202
start_line
int64
1
158k
end_line
int64
1
158k
repo
dict
801
build_table
def build_table(n_rows, img_dim): return wandb.Table( columns=["id", "image"], data=[ [i, wandb.Image(np.random.randint(0, 255, size=(img_dim, img_dim)))] for i in range(n_rows) ], )
python
tests/standalone_tests/artifact_table_load.py
38
45
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
802
safe_remove_dir
def safe_remove_dir(dir_name): if dir_name not in [".", "~", "/"] and os.path.exists(dir_name): shutil.rmtree(dir_name)
python
tests/standalone_tests/artifact_table_load.py
48
50
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
803
delete_cache
def delete_cache(): safe_remove_dir("./artifacts") safe_remove_dir("~/.cache/wandb") safe_remove_dir(artifacts.get_artifacts_cache()._cache_dir)
python
tests/standalone_tests/artifact_table_load.py
53
56
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
804
cleanup
def cleanup(): delete_cache() safe_remove_dir("./wandb")
python
tests/standalone_tests/artifact_table_load.py
59
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
805
main
def main(n_rows, img_dim, clear_cache=False): timer = { "LOG_TABLE": [None, None], "GET_TABLE": [None, None], "LOG_REF": [None, None], "GET_REF": [None, None], } delete_cache() with wandb.init() as run: table = build_table(n_rows, img_dim) artifact = wandb.Artifact("table_load_test", "table_load_test") artifact.add(table, "table") timer["LOG_TABLE"][0] = time.time() run.log_artifact(artifact) timer["LOG_TABLE"][1] = time.time() if clear_cache: delete_cache() with wandb.init() as run: artifact = run.use_artifact("table_load_test:latest") timer["GET_TABLE"][0] = time.time() table = artifact.get("table") timer["GET_TABLE"][1] = time.time() artifact = wandb.Artifact("table_load_test_ref", "table_load_test") artifact.add(table, "table_ref") timer["LOG_REF"][0] = time.time() run.log_artifact(artifact) timer["LOG_REF"][1] = time.time() if clear_cache: delete_cache() with wandb.init() as run: artifact = run.use_artifact("table_load_test_ref:latest") timer["GET_REF"][0] = time.time() table = artifact.get("table_ref") timer["GET_REF"][1] = time.time() print( "Version \tRows\tImgDim\tMBs\tCleared\tLOG_TAB\tGET_TAB\tLOG_REF\tGET_REF\t" ) print( "{:13}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t".format( wandb.__version__, n_rows, img_dim, round(n_rows * (img_dim * img_dim) / 1000000, 1), clear_cache, round(timer["LOG_TABLE"][1] - timer["LOG_TABLE"][0], 3), round(timer["GET_TABLE"][1] - timer["GET_TABLE"][0], 3), round(timer["LOG_REF"][1] - timer["LOG_REF"][0], 3), round(timer["GET_REF"][1] - timer["GET_REF"][0], 3), ) ) cleanup()
python
tests/standalone_tests/artifact_table_load.py
64
118
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
806
main
def main(): run = wandb.init(config=dict(this=2, that=4)) # not allowed # run.socket # run.pid # run.resume # run.program # run.args # run.storage_id # TODO: for compatibility print(run.mode) print(run.offline) # future # print(run.disabled) print(run.id) print(run.entity) print(run.project) print("GRP", run.group) print("JT", run.job_type) print(run.resumed) print(run.tags) print(run.sweep_id) print(run.config_static) print("PATH", run.path) run.save() # odd # tested elsewhere # run.use_artifact() # run.log_artifact() run.project_name() print(run.get_project_url()) print(run.get_sweep_url()) print(run.get_url()) print(run.name) print(run.notes) run.name = "dummy" # deprecated # print(run.description) # run.description = "dummy" # Not supported # print(run.host) print(run.dir) # Not supported # print(run.wandb_dir)
python
tests/standalone_tests/public_run.py
9
56
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
807
main
def main(): run = wandb.init(name=pathlib.Path(__file__).stem) run.log({"boom": 1}) run.finish()
python
tests/standalone_tests/basic.py
6
9
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
808
main
def main(): wandb.init(tensorboard=True) class ConvNet(nn.Module): def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 10, kernel_size=5) self.conv2 = nn.Conv2d(10, 20, kernel_size=5) self.conv2_drop = nn.Dropout2d() self.fc1 = nn.Linear(320, 50) self.fc2 = nn.Linear(50, 10) def forward(self, x): x = F.relu(F.max_pool2d(self.conv1(x), 2)) x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2)) x = x.view(-1, 320) x = F.relu(self.fc1(x)) x = F.dropout(x, training=self.training) x = self.fc2(x) return F.log_softmax(x, dim=1) writer = SummaryWriter() net = ConvNet() wandb.watch(net, log_freq=2) for i in range(10): output = net(torch.ones((64, 1, 28, 28))) loss = F.mse_loss(output, torch.ones((64, 10))) output.backward(torch.ones(64, 10)) writer.add_scalar("loss", loss / 64, i + 1) writer.add_image("example", torch.ones((1, 28, 28)), i + 1) writer.close()
python
tests/standalone_tests/pytorch_tensorboardX.py
8
38
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
809
__init__
def __init__(self): super().__init__() self.conv1 = nn.Conv2d(1, 10, kernel_size=5) self.conv2 = nn.Conv2d(10, 20, kernel_size=5) self.conv2_drop = nn.Dropout2d() self.fc1 = nn.Linear(320, 50) self.fc2 = nn.Linear(50, 10)
python
tests/standalone_tests/pytorch_tensorboardX.py
12
18
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
810
forward
def forward(self, x): x = F.relu(F.max_pool2d(self.conv1(x), 2)) x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2)) x = x.view(-1, 320) x = F.relu(self.fc1(x)) x = F.dropout(x, training=self.training) x = self.fc2(x) return F.log_softmax(x, dim=1)
python
tests/standalone_tests/pytorch_tensorboardX.py
20
27
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
811
cleanup
def cleanup(): if os.path.isdir("artifacts"): shutil.rmtree("artifacts") if os.path.isdir(LOCAL_FOLDER_NAME): shutil.rmtree(LOCAL_FOLDER_NAME) if os.path.isdir("wandb"): shutil.rmtree("wandb") if os.path.isfile(LOCAL_ASSET_NAME): os.remove(LOCAL_ASSET_NAME) if os.path.isfile("model.pkl"): os.remove("model.pkl")
python
tests/standalone_tests/dsviz_demo.py
64
78
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
812
download_data
def download_data(): global train_ids if not os.path.exists(LOCAL_ASSET_NAME): os.system(f"curl {DL_URL} --output {LOCAL_ASSET_NAME}") if not os.path.exists(LOCAL_FOLDER_NAME): os.system(f"tar xzf {LOCAL_ASSET_NAME}") train_ids = [ name.split(".")[0] for name in os.listdir(train_dir) if name.split(".")[0] != "" ]
python
tests/standalone_tests/dsviz_demo.py
81
91
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
813
_check_train_ids
def _check_train_ids(): if train_ids is None: raise Exception( "Please download the data using download_data() before attempting to access it." )
python
tests/standalone_tests/dsviz_demo.py
94
98
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
814
get_train_image_path
def get_train_image_path(ndx): _check_train_ids() return os.path.join(train_dir, train_ids[ndx] + ".jpg")
python
tests/standalone_tests/dsviz_demo.py
101
103
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
815
get_color_label_image_path
def get_color_label_image_path(ndx): _check_train_ids() return os.path.join(color_labels_dir, train_ids[ndx] + "_train_color.png")
python
tests/standalone_tests/dsviz_demo.py
106
108
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
816
get_label_image_path
def get_label_image_path(ndx): _check_train_ids() return os.path.join(labels_dir, train_ids[ndx] + "_train_id.png")
python
tests/standalone_tests/dsviz_demo.py
111
113
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
817
get_dominant_id_ndx
def get_dominant_id_ndx(np_image): if isinstance(np_image, wandb.Image): np_image = np.array(np_image.image) return BDD_ID_MAP[np.argmax(np.bincount(np_image.astype(int).flatten()))]
python
tests/standalone_tests/dsviz_demo.py
116
119
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
818
clean_artifacts_dir
def clean_artifacts_dir(): if os.path.isdir("artifacts"): shutil.rmtree("artifacts")
python
tests/standalone_tests/dsviz_demo.py
122
124
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
819
mask_to_bounding
def mask_to_bounding(np_image): if isinstance(np_image, wandb.Image): np_image = np.array(np_image.image) data = [] for id_num in BDD_IDS: matches = np_image == id_num col_count = np.where(matches.sum(axis=0))[0] row_count = np.where(matches.sum(axis=1))[0] if len(col_count) > 1 and len(row_count) > 1: min_x = col_count[0] / np_image.shape[1] max_x = col_count[-1] / np_image.shape[1] min_y = row_count[0] / np_image.shape[0] max_y = row_count[-1] / np_image.shape[0] data.append( { "position": { "minX": min_x, "maxX": max_x, "minY": min_y, "maxY": max_y, }, "class_id": id_num, } ) return data
python
tests/standalone_tests/dsviz_demo.py
127
154
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
820
get_scaled_train_image
def get_scaled_train_image(ndx, factor=2): return Image.open(get_train_image_path(ndx)).reduce(factor)
python
tests/standalone_tests/dsviz_demo.py
157
158
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
821
get_scaled_mask_label
def get_scaled_mask_label(ndx, factor=2): return np.array(Image.open(get_label_image_path(ndx)).reduce(factor))
python
tests/standalone_tests/dsviz_demo.py
161
162
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
822
get_scaled_bounding_boxes
def get_scaled_bounding_boxes(ndx, factor=2): return mask_to_bounding( np.array(Image.open(get_label_image_path(ndx)).reduce(factor)) )
python
tests/standalone_tests/dsviz_demo.py
165
168
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
823
get_scaled_color_mask
def get_scaled_color_mask(ndx, factor=2): return Image.open(get_color_label_image_path(ndx)).reduce(factor)
python
tests/standalone_tests/dsviz_demo.py
171
172
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
824
get_dominant_class
def get_dominant_class(label_mask): return BDD_CLASSES[get_dominant_id_ndx(label_mask)]
python
tests/standalone_tests/dsviz_demo.py
175
176
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
825
__init__
def __init__(self, n_classes): self.n_classes = n_classes
python
tests/standalone_tests/dsviz_demo.py
180
181
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
826
train
def train(self, images, masks): self.min = images.min() self.max = images.max() images = (images - self.min) / (self.max - self.min) step = 1.0 / n_classes self.quantiles = list( np.quantile(images, [i * step for i in range(self.n_classes)]) ) self.quantiles.append(1.0) self.outshape = masks.shape
python
tests/standalone_tests/dsviz_demo.py
183
192
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
827
predict
def predict(self, images): results = np.zeros((images.shape[0], self.outshape[1], self.outshape[2])) images = ((images - self.min) / (self.max - self.min)).mean(axis=3) for i in range(self.n_classes): results[ (self.quantiles[i] < images) & (images <= self.quantiles[i + 1]) ] = BDD_IDS[i] return results
python
tests/standalone_tests/dsviz_demo.py
194
201
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
828
save
def save(self, file_path): with open(file_path, "wb") as file: pickle.dump(self, file)
python
tests/standalone_tests/dsviz_demo.py
203
205
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
829
load
def load(file_path): model = None with open(file_path, "rb") as file: model = pickle.load(file) return model
python
tests/standalone_tests/dsviz_demo.py
208
212
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
830
iou
def iou(mask_a, mask_b, class_id): return np.nan_to_num( ((mask_a == class_id) & (mask_b == class_id)).sum(axis=(1, 2)) / ((mask_a == class_id) | (mask_b == class_id)).sum(axis=(1, 2)), 0, 0, 0, )
python
tests/standalone_tests/dsviz_demo.py
215
222
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
831
score_model
def score_model(model, x_data, mask_data, n_classes): results = model.predict(x_data) return np.array([iou(results, mask_data, i) for i in BDD_IDS]).T, results
python
tests/standalone_tests/dsviz_demo.py
225
227
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
832
make_datasets
def make_datasets(data_table, n_classes): n_samples = len(data_table.data) # n_classes = len(BDD_CLASSES) height = data_table.data[0][1].image.height width = data_table.data[0][1].image.width train_data = np.array( [ np.array(data_table.data[i][1].image).reshape(height, width, 3) for i in range(n_samples) ] ) mask_data = np.array( [ np.array(data_table.data[i][3].image).reshape(height, width) for i in range(n_samples) ] ) return train_data, mask_data
python
tests/standalone_tests/dsviz_demo.py
230
248
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
833
main
def main(): try: # Download the data if not already download_data() # Initialize the run with wandb.init( project=WANDB_PROJECT, # The project to register this Run to job_type="create_dataset", # The type of this Run. Runs of the same type can be grouped together in the UI config={ # Custom configuration parameters which you might want to tune or adjust for the Run "num_examples": NUM_EXAMPLES, # The number of raw samples to include. "scale_factor": 2, # The scaling factor for the images }, ) as run: # Setup a WandB Classes object. This will give additional metadata for visuals class_set = wandb.Classes( [{"name": name, "id": id} for name, id in zip(BDD_CLASSES, BDD_IDS)] ) # Setup a WandB Table object to hold our dataset table = wandb.Table( columns=[ "id", "train_image", "colored_image", "label_mask", "dominant_class", ] ) # Fill up the table for ndx in range(run.config["num_examples"]): # First, we will build a wandb.Image to act as our raw example object # classes: the classes which map to masks and/or box metadata # masks: the mask metadata. In this case, we use a 2d array where each cell corresponds to the label (this comes directlyfrom the dataset) # boxes: the bounding box metadata. For example sake, we create bounding boxes by looking at the mask data and creating boxes which fully encolose each class. # The data is an array of objects like: # "position": { # "minX": minX, # "maxX": maxX, # "minY": minY, # "maxY": maxY, # }, # "class_id" : id_num, # } example = wandb.Image( get_scaled_train_image(ndx, run.config.scale_factor), classes=class_set, masks={ "ground_truth": { "mask_data": get_scaled_mask_label( ndx, run.config.scale_factor ) }, }, boxes={ "ground_truth": { "box_data": get_scaled_bounding_boxes( ndx, run.config.scale_factor ) } }, ) # Next, we create two additional images which may be helpful during analysis. Notice that the additional metadata is optional. color_label = wandb.Image( get_scaled_color_mask(ndx, run.config.scale_factor) ) label_mask = wandb.Image( get_scaled_mask_label(ndx, run.config.scale_factor) ) # Finally, we add a row of our newly constructed data. table.add_data( train_ids[ndx], example, color_label, label_mask, get_dominant_class(label_mask), ) # Create an Artifact (versioned folder) artifact = wandb.Artifact(name="raw_data", type="dataset") # add the table to the artifact artifact.add(table, "raw_examples") # Finally, log the artifact run.log_artifact(artifact) print("Step 1/5 Complete") # This step should look familiar by now: with wandb.init( project=WANDB_PROJECT, job_type="split_dataset", config={ "train_pct": 0.7, }, ) as run: # Get the latest version of the artifact. Notice the name alias follows this convention: "<ARTIFACT_NAME>:<VERSION>" # when version is set to "latest", then the latest version will always be used. However, you can pin to a version by # using an alias such as "raw_data:v0" dataset_artifact = run.use_artifact("raw_data:latest") # Next, we "get" the table by the same name that we saved it in the last run. data_table = dataset_artifact.get("raw_examples") # Now we can build two separate artifacts for later use. We will first split the raw table into two parts, # then create two different artifacts, each of which will hold our new tables. We create two artifacts so that # in future runs, we can selectively decide which subsets of data to download. # Create the tables train_count = int(len(data_table.data) * run.config.train_pct) train_table = wandb.Table( columns=data_table.columns, data=data_table.data[:train_count] ) test_table = wandb.Table( columns=data_table.columns, data=data_table.data[train_count:] ) # Create the artifacts train_artifact = wandb.Artifact("train_data", "dataset") test_artifact = wandb.Artifact("test_data", "dataset") # Save the tables to the artifacts train_artifact.add(train_table, "train_table") test_artifact.add(test_table, "test_table") # Log the artifacts out as outputs of the run run.log_artifact(train_artifact) run.log_artifact(test_artifact) print("Step 2/5 Complete") # Again, create a run. with wandb.init(project=WANDB_PROJECT, job_type="model_train") as run: # Similar to before, we will load in the artifact and asset we need. In this case, the training data train_artifact = run.use_artifact("train_data:latest") train_table = train_artifact.get("train_table") # Next, we split out the labels and train the model train_data, mask_data = make_datasets(train_table, n_classes) model = ExampleSegmentationModel(n_classes) model.train(train_data, mask_data) # Finally we score the model. Behind the scenes, we score each mask on it's IOU score. scores, results = score_model(model, train_data, mask_data, n_classes) # Let's create a new table. Notice that we create many columns - an evaluation score for each class type. results_table = wandb.Table( columns=["id", "pred_mask", "dominant_pred"] + BDD_CLASSES, # Data construction is similar to before, but we now use the predicted masks and bound boxes. data=[ [ train_table.data[ndx][0], wandb.Image( train_table.data[ndx][1], masks={ "train_predicted_truth": { "mask_data": results[ndx], }, }, boxes={ "ground_truth": { "box_data": mask_to_bounding(results[ndx]) } }, ), BDD_CLASSES[get_dominant_id_ndx(results[ndx])], ] + list(row) for ndx, row in enumerate(scores) ], ) # We create an artifact, add the table, and log it as part of the run. results_artifact = wandb.Artifact("train_results", "dataset") results_artifact.add(results_table, "train_iou_score_table") run.log_artifact(results_artifact) # Finally, let's save the model as a flat file and add that to it's own artifact. model.save("model.pkl") model_artifact = wandb.Artifact("trained_model", "model") model_artifact.add_file("model.pkl") run.log_artifact(model_artifact) print("Step 3/5 Complete") with wandb.init(project=WANDB_PROJECT, job_type="model_eval") as run: # Retrieve the test data test_artifact = run.use_artifact("test_data:latest") test_table = test_artifact.get("test_table") test_data, mask_data = make_datasets(test_table, n_classes) # Download the saved model file. model_artifact = run.use_artifact("trained_model:latest") path = model_artifact.get_path("model.pkl").download() # Load the model from the file and score it model = ExampleSegmentationModel.load(path) scores, results = score_model(model, test_data, mask_data, n_classes) # Create a predicted score table similar to step 3. results_artifact = wandb.Artifact("test_results", "dataset") data = [ [ test_table.data[ndx][0], wandb.Image( test_table.data[ndx][1], masks={ "test_predicted_truth": { "mask_data": results[ndx], }, }, boxes={ "ground_truth": {"box_data": mask_to_bounding(results[ndx])} }, ), BDD_CLASSES[get_dominant_id_ndx(results[ndx])], ] + list(row) for ndx, row in enumerate(scores) ] # And log out the results. results_artifact.add( wandb.Table( ["id", "pred_mask_test", "dominant_pred_test"] + BDD_CLASSES, data=data, ), "test_iou_score_table", ) run.log_artifact(results_artifact) print("Step 4/5 Complete") with wandb.init(project=WANDB_PROJECT, job_type="model_result_analysis") as run: # Retrieve the original raw dataset dataset_artifact = run.use_artifact("raw_data:latest") data_table = dataset_artifact.get("raw_examples") # Retrieve the train and test score tables train_artifact = run.use_artifact("train_results:latest") train_table = train_artifact.get("train_iou_score_table") test_artifact = run.use_artifact("test_results:latest") test_table = test_artifact.get("test_iou_score_table") # Join the tables on ID column and log them as outputs. train_results = wandb.JoinedTable(train_table, data_table, "id") test_results = wandb.JoinedTable(test_table, data_table, "id") artifact = wandb.Artifact("summary_results", "dataset") artifact.add(train_results, "train_results") artifact.add(test_results, "test_results") run.log_artifact(artifact) print("Step 5/5 Complete") if WANDB_PROJECT_ENV is not None: os.environ["WANDB_PROJECT"] = WANDB_PROJECT_ENV if WANDB_SILENT_ENV is not None: os.environ["WANDB_SILENT"] = WANDB_SILENT_ENV finally: cleanup()
python
tests/standalone_tests/dsviz_demo.py
251
517
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
834
gen_files
def gen_files(n_files, max_small_size, max_large_size): bufsize = max_large_size * 100 # create a random buffer to pull from. drawing ranges from this buffer is # orders of magnitude faster than creating random contents for each file. buf = "".join(random.choices(string.ascii_uppercase + string.digits, k=bufsize)) fnames = [] for i in tqdm(range(n_files)): full_dir = os.path.join("source_files", "%s" % (i % 4)) os.makedirs(full_dir, exist_ok=True) fname = os.path.join(full_dir, "%s.txt" % i) fnames.append(fname) with open(fname, "w") as f: small = random.random() < 0.5 if small: size = int(random.random() * max_small_size) else: size = int(random.random() * max_large_size) start_pos = int(random.random() * (bufsize - size)) f.write(buf[start_pos : start_pos + size]) return fnames
python
tests/standalone_tests/artifact_load.py
76
98
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
835
proc_version_writer
def proc_version_writer( stop_queue, stats_queue, project_name, fnames, artifact_name, files_per_version_min, files_per_version_max, blocking, ): while True: try: stop_queue.get_nowait() print("Writer stopping") return except queue.Empty: pass print("Writer initing run") with wandb.init(reinit=True, project=project_name, job_type="writer") as run: files_in_version = random.randrange( files_per_version_min, files_per_version_max ) version_fnames = random.sample(fnames, files_in_version) art = wandb.Artifact(artifact_name, type="dataset") for version_fname in version_fnames: art.add_file(version_fname) run.log_artifact(art) if blocking: art.wait() assert art.version is not None stats_queue.put( {"write_artifact_count": 1, "write_total_files": files_in_version} )
python
tests/standalone_tests/artifact_load.py
101
134
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
836
_train
def _train(chunk, artifact_name, project_name, group_name): with wandb.init( reinit=True, project=project_name, group=group_name, job_type="writer" ) as run: art = wandb.Artifact(artifact_name, type="dataset") for file in chunk: art.add_file(file) run.upsert_artifact(art)
python
tests/standalone_tests/artifact_load.py
137
144
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
837
proc_version_writer_distributed
def proc_version_writer_distributed( stop_queue, stats_queue, project_name, fnames, artifact_name, files_per_version_min, files_per_version_max, fanout, blocking, ): while True: try: stop_queue.get_nowait() print("Writer stopping") return except queue.Empty: pass print("Writer initing run") group_name = "".join(random.choice(string.ascii_uppercase) for _ in range(8)) files_in_version = random.randrange( files_per_version_min, files_per_version_max ) version_fnames = random.sample(fnames, files_in_version) chunk_size = max(int(len(version_fnames) / fanout), 1) chunks = [ version_fnames[i : i + chunk_size] for i in range(0, len(version_fnames), chunk_size) ] # TODO: Once we resolve issues with spawn or switch to fork, we can run these in separate processes # instead of running them serially. for i in range(fanout): _train(chunks[i], artifact_name, project_name, group_name) with wandb.init( reinit=True, project=project_name, group=group_name, job_type="writer" ) as run: print(f"Committing {group_name}") art = wandb.Artifact(artifact_name, type="dataset") run.finish_artifact(art) stats_queue.put( {"write_artifact_count": 1, "write_total_files": files_in_version} )
python
tests/standalone_tests/artifact_load.py
147
191
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
838
proc_version_reader
def proc_version_reader( stop_queue, stats_queue, project_name, artifact_name, reader_id ): api = wandb.Api() # initial sleep to ensure we've created the sequence. Public API fails # with a nasty error if not. time.sleep(10) while True: try: stop_queue.get_nowait() print("Reader stopping") return except queue.Empty: pass versions = api.artifact_versions("dataset", artifact_name) versions = [v for v in versions if v.state == "COMMITTED"] if len(versions) == 0: time.sleep(5) continue version = random.choice(versions) print("Reader initing run to read: ", version) stats_queue.put({"read_artifact_count": 1}) with wandb.init(reinit=True, project=project_name, job_type="reader") as run: try: run.use_artifact(version) except Exception as e: stats_queue.put({"read_use_error": 1}) print(f"Reader caught error on use_artifact: {e}") updated_version = api.artifact(version.name) if updated_version.state != "DELETED": raise Exception( "Artifact exception caught but artifact not DELETED" ) continue print("Reader downloading: ", version) try: version.checkout("read-%s" % reader_id) except Exception as e: stats_queue.put({"read_download_error": 1}) print(f"Reader caught error on version.download: {e}") updated_version = api.artifact(version.name) if updated_version.state != "DELETED": raise Exception( "Artifact exception caught but artifact not DELETED" ) continue print("Reader verifying: ", version) version.verify(f"read-{reader_id}") print("Reader verified: ", version)
python
tests/standalone_tests/artifact_load.py
194
242
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
839
proc_version_deleter
def proc_version_deleter( stop_queue, stats_queue, artifact_name, min_versions, delete_period_max ): api = wandb.Api() # initial sleep to ensure we've created the sequence. Public API fails # with a nasty error if not. time.sleep(10) while True: try: stop_queue.get_nowait() print("Deleter stopping") return except queue.Empty: pass versions = api.artifact_versions("dataset", artifact_name) # Don't try to delete versions that have aliases, the backend won't allow it versions = [ v for v in versions if v.state == "COMMITTED" and len(v.aliases) == 0 ] if len(versions) > min_versions: version = random.choice(versions) print("Delete version", version) stats_queue.put({"delete_count": 1}) start_time = time.time() version.delete() stats_queue.put({"delete_total_time": time.time() - start_time}) print("Delete version complete", version) time.sleep(random.randrange(delete_period_max))
python
tests/standalone_tests/artifact_load.py
245
272
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
840
proc_cache_garbage_collector
def proc_cache_garbage_collector(stop_queue, cache_gc_period_max): while True: try: stop_queue.get_nowait() print("GC stopping") return except queue.Empty: pass time.sleep(random.randrange(cache_gc_period_max)) print("Cache GC") os.system("rm -rf ~/.cache/wandb/artifacts")
python
tests/standalone_tests/artifact_load.py
275
285
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
841
proc_bucket_garbage_collector
def proc_bucket_garbage_collector(stop_queue, bucket_gc_period_max): while True: time.sleep(random.randrange(bucket_gc_period_max)) print("Bucket GC") # TODO: implement bucket gc
python
tests/standalone_tests/artifact_load.py
288
292
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
842
main
def main(argv): # noqa: C901 args = parser.parse_args() print("Load test starting") project_name = args.project if project_name is None: project_name = "artifacts-load-test-%s" % str(datetime.now()).replace( " ", "-" ).replace(":", "-").replace(".", "-") env_project = os.environ.get("WANDB_PROJECT") sweep_id = os.environ.get("WANDB_SWEEP_ID") if sweep_id: del os.environ["WANDB_SWEEP_ID"] wandb_config_paths = os.environ.get("WANDB_CONFIG_PATHS") if wandb_config_paths: del os.environ["WANDB_CONFIG_PATHS"] wandb_run_id = os.environ.get("WANDB_RUN_ID") if wandb_run_id: del os.environ["WANDB_RUN_ID"] # set global entity and project before chdir'ing from wandb.apis import InternalApi api = InternalApi() settings_entity = api.settings("entity") settings_base_url = api.settings("base_url") os.environ["WANDB_ENTITY"] = os.environ.get("LOAD_TEST_ENTITY") or settings_entity os.environ["WANDB_PROJECT"] = project_name os.environ["WANDB_BASE_URL"] = ( os.environ.get("LOAD_TEST_BASE_URL") or settings_base_url ) # Change dir to avoid littering code directory pwd = os.getcwd() tempdir = tempfile.TemporaryDirectory() os.chdir(tempdir.name) artifact_name = "load-artifact-" + "".join( random.choices(string.ascii_lowercase + string.digits, k=10) ) print("Generating source data") source_file_names = gen_files( args.gen_n_files, args.gen_max_small_size, args.gen_max_large_size ) print("Done generating source data") procs = [] stop_queue = multiprocessing.Queue() stats_queue = multiprocessing.Queue() # start all processes # writers for i in range(args.num_writers): file_names = source_file_names if args.non_overlapping_writers: chunk_size = int(len(source_file_names) / args.num_writers) file_names = source_file_names[i * chunk_size : (i + 1) * chunk_size] if args.distributed_fanout > 1: p = multiprocessing.Process( target=proc_version_writer_distributed, args=( stop_queue, stats_queue, project_name, file_names, artifact_name, args.files_per_version_min, args.files_per_version_max, args.distributed_fanout, args.blocking, ), ) else: p = multiprocessing.Process( target=proc_version_writer, args=( stop_queue, stats_queue, project_name, file_names, artifact_name, args.files_per_version_min, args.files_per_version_max, args.blocking, ), ) p.start() procs.append(p) # readers for i in range(args.num_readers): p = multiprocessing.Process( target=proc_version_reader, args=(stop_queue, stats_queue, project_name, artifact_name, i), ) p.start() procs.append(p) # deleters for _ in range(args.num_deleters): p = multiprocessing.Process( target=proc_version_deleter, args=( stop_queue, stats_queue, artifact_name, args.min_versions_before_delete, args.delete_period_max, ), ) p.start() procs.append(p) # cache garbage collector if args.cache_gc_period_max is None: print("Testing cache GC process not enabled!") else: p = multiprocessing.Process( target=proc_cache_garbage_collector, args=(stop_queue, args.cache_gc_period_max), ) p.start() procs.append(p) # reset environment os.environ["WANDB_ENTITY"] = settings_entity os.environ["WANDB_BASE_URL"] = settings_base_url if env_project is None: del os.environ["WANDB_PROJECT"] else: os.environ["WANDB_PROJECT"] = env_project if sweep_id: os.environ["WANDB_SWEEP_ID"] = sweep_id if wandb_config_paths: os.environ["WANDB_CONFIG_PATHS"] = wandb_config_paths if wandb_run_id: os.environ["WANDB_RUN_ID"] = wandb_run_id # go back to original dir os.chdir(pwd) # test phase start_time = time.time() stats = defaultdict(int) run = wandb.init(job_type="main-test-phase") run.config.update(args) while time.time() - start_time < args.test_phase_seconds: stat_update = None try: stat_update = stats_queue.get(True, 5000) except queue.Empty: pass print("** Test time: %s" % (time.time() - start_time)) if stat_update: for k, v in stat_update.items(): stats[k] += v wandb.log(stats) print("Test phase time expired") # stop all processes and wait til all are done for _ in range(len(procs)): stop_queue.put(True) print("Waiting for processes to stop") fail = False for proc in procs: proc.join() if proc.exitcode != 0: print("FAIL! Test phase failed") fail = True sys.exit(1) # drain remaining stats while True: try: stat_update = stats_queue.get_nowait() except queue.Empty: break for k, v in stat_update.items(): stats[k] += v print("Stats") import pprint pprint.pprint(dict(stats)) if fail: print("FAIL! Test phase failed") sys.exit(1) else: print("Test phase successfully completed") print("Starting verification phase") os.environ["WANDB_ENTITY"] = os.environ.get("LOAD_TEST_ENTITY") or settings_entity os.environ["WANDB_PROJECT"] = project_name os.environ["WANDB_BASE_URL"] = ( os.environ.get("LOAD_TEST_BASE_URL") or settings_base_url ) data_api = wandb.Api() # we need list artifacts by walking runs, accessing via # project.artifactType.artifacts only returns committed artifacts for run in data_api.runs("{}/{}".format(api.settings("entity"), project_name)): for v in run.logged_artifacts(): # TODO: allow deleted once we build deletion support if v.state != "COMMITTED" and v.state != "DELETED": print("FAIL! Artifact version not committed or deleted: %s" % v) sys.exit(1) print("Verification succeeded")
python
tests/standalone_tests/artifact_load.py
295
508
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
843
dummy_torch_tensor
def dummy_torch_tensor(size, requires_grad=True): if parse_version(torch.__version__) >= parse_version("0.4"): return torch.ones(size, requires_grad=requires_grad) else: return torch.autograd.Variable(torch.ones(size), requires_grad=requires_grad)
python
tests/standalone_tests/all_media_types.py
17
21
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
844
main
def main(): wandb.init() histogram_small_literal = wandb.Histogram(np_histogram=([1, 2, 4], [3, 10, 20, 0])) histogram_large_random = wandb.Histogram(numpy.random.randint(255, size=(1000))) numpy_array = numpy.random.rand(1000) torch_tensor = torch.rand(1000, 1000) data_frame = pandas.DataFrame( # noqa: F841 data=numpy.random.rand(1000), columns=["col"] ) tensorflow_variable_single = tensorflow.Variable(543.01, tensorflow.float32) tensorflow_variable_multi = tensorflow.Variable([[2, 3], [7, 11]], tensorflow.int32) plot_scatter = go.Figure( # plotly data=go.Scatter(x=[0, 1, 2]), layout=go.Layout(title=go.layout.Title(text="A Bar Chart")), ) image_data = numpy.zeros((28, 28)) image_cool = wandb.Image(image_data, caption="Cool zeros") image_nice = wandb.Image(image_data, caption="Nice zeros") image_random = wandb.Image(numpy.random.randint(255, size=(28, 28, 3))) image_pil = wandb.Image(PIL.Image.new("L", (28, 28))) plt.plot([1, 2, 3, 4]) plt.ylabel("some interesting numbers") image_matplotlib_plot = wandb.Image(plt) # matplotlib_plot = plt audio_data = numpy.random.uniform(-1, 1, 44100) sample_rate = 44100 caption1 = "This is what a dog sounds like" caption2 = "This is what a chicken sounds like" # test with all captions audio1 = wandb.Audio(audio_data, sample_rate=sample_rate, caption=caption1) audio2 = wandb.Audio(audio_data, sample_rate=sample_rate, caption=caption2) # test with no captions audio3 = wandb.Audio(audio_data, sample_rate=sample_rate) audio4 = wandb.Audio(audio_data, sample_rate=sample_rate) # test with some captions audio5 = wandb.Audio(audio_data, sample_rate=sample_rate) audio6 = wandb.Audio(audio_data, sample_rate=sample_rate, caption=caption2) html = wandb.Html("<html><body><h1>Hello</h1></body></html>") table_default_columns = wandb.Table() table_default_columns.add_data("Some awesome text", "Positive", "Negative") table_custom_columns = wandb.Table(["Foo", "Bar"]) table_custom_columns.add_data("So", "Cool") table_custom_columns.add_data("&", "Rad") # plot_figure = matplotlib.pyplot.plt.figure() # c1 = matplotlib.pyplot.plt.Circle((0.2, 0.5), 0.2, color='r') # ax = matplotlib.pyplot.plt.gca() # ax.add_patch(c1) # matplotlib.pyplot.plt.axis('scaled') # pytorch model graph # alex = models.AlexNet() # graph = wandb.wandb_torch.TorchGraph.hook_torch(alex) # alex.forward(dummy_torch_tensor((2, 3, 224, 224))) with tensorflow.Session().as_default() as sess: sess.run(tensorflow.global_variables_initializer()) wandb.run.summary.update( { "histogram-small-literal-summary": histogram_small_literal, "histogram-large-random-summary": histogram_large_random, "numpy-array-summary": numpy_array, "torch-tensor-summary": torch_tensor, # bare dataframes in summary and history removed in 0.10.21 # 'data-frame-summary': data_frame, "image-cool-summary": image_cool, "image-nice-summary": image_nice, "image-random-summary": image_random, "image-pil-summary": image_pil, "image-plot-summary": image_matplotlib_plot, "image-list-summary": [image_cool, image_nice, image_random, image_pil], # Doesn't work, because something has happened to the MPL object (MPL may # be doing magical scope stuff). If you log it right after creating it, # it works fine. # "matplotlib-plot": matplotlib_plot, "audio1-summary": audio1, "audio2-summary": audio2, "audio3-summary": audio3, "audio4-summary": audio4, "audio5-summary": audio5, "audio6-summary": audio6, "audio-list-summary": [audio1, audio2, audio3, audio4, audio5, audio6], "html-summary": html, "table-default-columns-summary": table_default_columns, "table-custom-columns-summary": table_custom_columns, "plot-scatter-summary": plot_scatter, # "plot_figure": plot_figure, "tensorflow-variable-single-summary": tensorflow_variable_single, "tensorflow-variable-multi-summary": tensorflow_variable_multi, # "graph-summary": graph, } ) for _ in range(10): wandb.run.log( { "string": "string", "histogram-small-literal": histogram_small_literal, "histogram-large-random": histogram_large_random, "numpy-array": numpy_array, "torch-tensor": torch_tensor, # "data-frame": data_frame, # not supported yet "image-cool": image_cool, "image-nice": image_nice, "image-random": image_random, "image-pil": image_pil, "image-plot": image_matplotlib_plot, "image-list": [image_cool, image_nice, image_random, image_pil], # "matplotlib-plot": matplotlib_plot, "audio1": audio1, "audio2": audio2, "audio3": audio3, "audio4": audio4, "audio5": audio5, "audio6": audio6, "audio-list": [audio1, audio2, audio3, audio4, audio5, audio6], "html": html, "table-default-columns": table_default_columns, "table-custom-columns": table_custom_columns, "plot-scatter": plot_scatter, # "plot_figure": plot_figure, "tensorflow-variable-single": tensorflow_variable_single, "tensorflow-variable-multi": tensorflow_variable_multi, # "graph": graph, } ) wandb.run.summary.update( { "histogram-small-literal-summary": histogram_small_literal, "histogram-large-random-summary": histogram_large_random, "numpy-array-summary": numpy_array, "torch-tensor-summary": torch_tensor, # bare dataframes in summary and history removed in 0.10.21 # "data-frame-summary": data_frame, "image-cool-summary": image_cool, "image-nice-summary": image_nice, "image-random-summary": image_random, "image-pil-summary": image_pil, "image-plot-summary": image_matplotlib_plot, "image-list-summary": [image_cool, image_nice, image_random, image_pil], # "matplotlib-plot": matplotlib_plot, "audio1-summary": audio1, "audio2-summary": audio2, "audio3-summary": audio3, "audio4-summary": audio4, "audio5-summary": audio5, "audio6-summary": audio6, "audio-list-summary": [audio1, audio2, audio3, audio4, audio5, audio6], "html-summary": html, "table-default-columns-summary": table_default_columns, "table-custom-columns-summary": table_custom_columns, "plot-scatter-summary": plot_scatter, # "plot_figure": plot_figure, "tensorflow-variable-single-summary": tensorflow_variable_single, "tensorflow-variable-multi-summary": tensorflow_variable_multi, # "graph-summary": graph, } ) # history.add({ # "tensorflow_variable_single": tensorflow_variable_single, # "tensorflow_variable_multi": tensorflow_variable_single, # })
python
tests/standalone_tests/all_media_types.py
24
194
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
845
artifact_with_various_paths
def artifact_with_various_paths(): art = wandb.Artifact(type="artsy", name="my-artys") # internal file with open("random.txt", "w") as f: f.write("file1 %s" % random.random()) f.close() art.add_file(f.name) # internal file (using new_file) with art.new_file("a.txt") as f: f.write("hello %s" % random.random()) os.makedirs("./dir", exist_ok=True) with open("./dir/1.txt", "w") as f: f.write("1") with open("./dir/2.txt", "w") as f: f.write("2") art.add_dir("./dir") with open("bla.txt", "w") as f: f.write("BLAAAAAAAAAAH") # reference to local file art.add_reference("file://bla.txt") # # reference to s3 file art.add_reference( "s3://wandb-test-file-storage/annirudh/loadtest/19r6ajhm/requirements.txt" ) # # reference to s3 prefix # art.add_reference('s3://wandb-test-file-storage/annirudh/loadtest/19r6ajhm') # # http reference # art.add_reference('https://i.imgur.com/0ZfJ9xj.png') # # reference to unknown scheme # art.add_reference('detectron2://some-model', name='x') return art
python
tests/standalone_tests/artifact_storage.py
9
43
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
846
main
def main(argv): # set global entity and project before chdir'ing from wandb.apis import InternalApi api = InternalApi() os.environ["WANDB_ENTITY"] = api.settings("entity") os.environ["WANDB_PROJECT"] = api.settings("project") # Change dir to avoid litering code directory tempdir = tempfile.TemporaryDirectory() os.chdir(tempdir.name) with wandb.init(reinit=True, job_type="user") as run: # Use artifact that doesn't exist art2 = artifact_with_various_paths() run.use_artifact(art2, aliases="art2") with wandb.init(reinit=True, job_type="writer") as run: # Log artifact that doesn't exist art1 = artifact_with_various_paths() run.log_artifact(art1, aliases="art1") with wandb.init(reinit=True, job_type="reader") as run: # Downloading should probably fail or warn when your artifact contains # a path that can't be downloaded. print("Downloading art1") art = run.use_artifact("my-artys:art1") import pprint pprint.pprint(art._load_manifest().to_manifest_json()) # print(art.list()) art_dir = art.download() print(os.listdir(art_dir)) print("Art bla.txt reference", art.get_path("bla.txt").ref_target()) print( "Art requirements.txt reference", art.get_path("requirements.txt").ref_target(), ) print( "Art requirements.txt reference", art.get_path("requirements.txt").download(), ) print("Downloading art2") art = run.use_artifact("my-artys:art2") art_dir = art.download() art.verify() print(os.listdir(art_dir)) computed = wandb.Artifact("bla", type="dataset") computed.add_dir(art_dir) # These won't match, because we stored an s3 reference which uses the # etag, so the manifest's sadly aren't directly comparable print("Not expected to match because of s3 ref:") print("downloaded dig", art.digest) print("computed dig", computed.digest) print("downloaded manifest", art._load_manifest().to_manifest_json()) print("computed manifest", computed.manifest.to_manifest_json())
python
tests/standalone_tests/artifact_storage.py
46
106
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
847
func
def func(): entity, project = None, None run_id = None with wandb.init() as run: run_id = run.id artifact = wandb.Artifact(f"boom-name-{run_id}", type="boom-type") table = wandb.Table(columns=["boom_col"]) table.add_data(5) artifact.add(table, name="table") wandb.log({"data": 5}) wandb.log({"data": 10}) wandb.log_artifact(artifact) entity = run.entity project = run.project api = wandb.Api() api.artifact(f"{entity}/{project}/boom-name-{run_id}:v0") assert True
python
tests/standalone_tests/history_step_guardrail_log_artifact.py
11
29
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
848
main
def main(size: int) -> None: run = wandb.init(settings={"console": "off"}) run.log({f"v_{i}": i for i in range(size)}) run.finish()
python
tests/standalone_tests/log_large_data.py
7
11
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
849
main
def main(): run = wandb.init() history = 20 for i in range(history): if i % 10 == 0: print(i) run.log(dict(num=i)) time.sleep(0.1) print("done") run.finish()
python
tests/standalone_tests/mitm_tests/mem_pressure.py
8
17
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
850
test_uwsgi
def test_uwsgi(): with wandb.init() as run: dataset_name = "check_uwsgi_flask" artifact = wandb.Artifact(dataset_name, type="dataset") artifact.metadata["datasetName"] = dataset_name run.log_artifact(artifact) return jsonify(status="success", run=run.name), 200
python
tests/standalone_tests/executor_tests/flask_app.py
10
16
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
851
immutable_keys
def immutable_keys() -> List[str]: """These are env keys that shouldn't change within a single process. We use this to maintain certain values between multiple calls to wandb.init within a single process.""" return [ DIR, ENTITY, PROJECT, API_KEY, IGNORE, DISABLE_CODE, DISABLE_GIT, DOCKER, MODE, BASE_URL, ERROR_REPORTING, CRASH_NOSYNC_TIME, MAGIC, USERNAME, USER_EMAIL, DIR, SILENT, CONFIG_PATHS, ANONYMOUS, RUN_GROUP, JOB_TYPE, TAGS, RESUME, AGENT_REPORT_INTERVAL, HTTP_TIMEOUT, HOST, DATA_DIR, CACHE_DIR, USE_V1_ARTIFACTS, DISABLE_SSL, ]
python
wandb/env.py
88
122
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
852
_env_as_bool
def _env_as_bool( var: str, default: Optional[str] = None, env: Optional[Env] = None ) -> bool: if env is None: env = os.environ val = env.get(var, default) try: val = bool(strtobool(val)) # type: ignore except (AttributeError, ValueError): pass return val if isinstance(val, bool) else False
python
wandb/env.py
125
135
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
853
is_debug
def is_debug(default: Optional[str] = None, env: Optional[Env] = None) -> bool: return _env_as_bool(DEBUG, default=default, env=env)
python
wandb/env.py
138
139
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
854
error_reporting_enabled
def error_reporting_enabled() -> bool: return _env_as_bool(ERROR_REPORTING, default="True")
python
wandb/env.py
142
143
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
855
ssl_disabled
def ssl_disabled() -> bool: return _env_as_bool(DISABLE_SSL, default="False")
python
wandb/env.py
146
147
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
856
get_error_reporting
def get_error_reporting( default: Union[bool, str] = True, env: Optional[Env] = None, ) -> Union[bool, str]: if env is None: env = os.environ return env.get(ERROR_REPORTING, default)
python
wandb/env.py
150
157
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
857
get_run
def get_run(default: Optional[str] = None, env: Optional[Env] = None) -> Optional[str]: if env is None: env = os.environ return env.get(RUN_ID, default)
python
wandb/env.py
160
164
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
858
get_args
def get_args( default: Optional[List[str]] = None, env: Optional[Env] = None ) -> Optional[List[str]]: if env is None: env = os.environ if env.get(ARGS): try: return json.loads(env.get(ARGS, "[]")) # type: ignore except ValueError: return None else: return default or sys.argv[1:]
python
wandb/env.py
167
178
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
859
get_docker
def get_docker( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(DOCKER, default)
python
wandb/env.py
181
187
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
860
get_http_timeout
def get_http_timeout(default: int = 10, env: Optional[Env] = None) -> int: if env is None: env = os.environ return int(env.get(HTTP_TIMEOUT, default))
python
wandb/env.py
190
194
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
861
get_ignore
def get_ignore( default: Optional[List[str]] = None, env: Optional[Env] = None ) -> Optional[List[str]]: if env is None: env = os.environ ignore = env.get(IGNORE) if ignore is not None: return ignore.split(",") else: return default
python
wandb/env.py
197
206
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
862
get_project
def get_project( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(PROJECT, default)
python
wandb/env.py
209
215
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
863
get_username
def get_username( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(USERNAME, default)
python
wandb/env.py
218
224
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
864
get_user_email
def get_user_email( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(USER_EMAIL, default)
python
wandb/env.py
227
233
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
865
get_entity
def get_entity( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(ENTITY, default)
python
wandb/env.py
236
242
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
866
get_base_url
def get_base_url( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ base_url = env.get(BASE_URL, default) return base_url.rstrip("/") if base_url is not None else base_url
python
wandb/env.py
245
253
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
867
get_app_url
def get_app_url( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(APP_URL, default)
python
wandb/env.py
256
262
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
868
get_show_run
def get_show_run(default: Optional[str] = None, env: Optional[Env] = None) -> bool: if env is None: env = os.environ return bool(env.get(SHOW_RUN, default))
python
wandb/env.py
265
269
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
869
get_description
def get_description( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(DESCRIPTION, default)
python
wandb/env.py
272
278
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
870
get_tags
def get_tags(default: str = "", env: Optional[Env] = None) -> List[str]: if env is None: env = os.environ return [tag for tag in env.get(TAGS, default).split(",") if tag]
python
wandb/env.py
281
285
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
871
get_dir
def get_dir(default: Optional[str] = None, env: Optional[Env] = None) -> Optional[str]: if env is None: env = os.environ return env.get(DIR, default)
python
wandb/env.py
288
291
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
872
get_config_paths
def get_config_paths( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ return env.get(CONFIG_PATHS, default)
python
wandb/env.py
294
299
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
873
get_agent_report_interval
def get_agent_report_interval( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[int]: if env is None: env = os.environ val = env.get(AGENT_REPORT_INTERVAL, default) try: val = int(val) # type: ignore except ValueError: val = None # silently ignore env format errors, caller should handle. return val
python
wandb/env.py
302
312
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
874
get_agent_kill_delay
def get_agent_kill_delay( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[int]: if env is None: env = os.environ val = env.get(AGENT_KILL_DELAY, default) try: val = int(val) # type: ignore except ValueError: val = None # silently ignore env format errors, caller should handle. return val
python
wandb/env.py
315
325
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
875
get_crash_nosync_time
def get_crash_nosync_time( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[int]: if env is None: env = os.environ val = env.get(CRASH_NOSYNC_TIME, default) try: val = int(val) # type: ignore except ValueError: val = None # silently ignore env format errors, caller should handle. return val
python
wandb/env.py
328
338
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
876
get_magic
def get_magic( default: Optional[str] = None, env: Optional[Env] = None ) -> Optional[str]: if env is None: env = os.environ val = env.get(MAGIC, default) return val
python
wandb/env.py
341
347
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
877
get_data_dir
def get_data_dir(env: Optional[Env] = None) -> str: default_dir = appdirs.user_data_dir("wandb") if env is None: env = os.environ val = env.get(DATA_DIR, default_dir) return val
python
wandb/env.py
350
355
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
878
get_cache_dir
def get_cache_dir(env: Optional[Env] = None) -> str: default_dir = appdirs.user_cache_dir("wandb") if env is None: env = os.environ val = env.get(CACHE_DIR, default_dir) return val
python
wandb/env.py
358
363
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
879
get_use_v1_artifacts
def get_use_v1_artifacts(env: Optional[Env] = None) -> bool: if env is None: env = os.environ val = bool(env.get(USE_V1_ARTIFACTS, False)) return val
python
wandb/env.py
366
370
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
880
get_agent_max_initial_failures
def get_agent_max_initial_failures( default: Optional[int] = None, env: Optional[Env] = None ) -> Optional[int]: if env is None: env = os.environ val = env.get(AGENT_MAX_INITIAL_FAILURES, default) try: val = int(val) # type: ignore except ValueError: val = default return val
python
wandb/env.py
373
383
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
881
set_entity
def set_entity(value: str, env: Optional[Env] = None) -> None: if env is None: env = os.environ env[ENTITY] = value
python
wandb/env.py
386
389
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
882
set_project
def set_project(value: str, env: Optional[Env] = None) -> None: if env is None: env = os.environ env[PROJECT] = value or "uncategorized"
python
wandb/env.py
392
395
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
883
should_save_code
def should_save_code() -> bool: save_code = _env_as_bool(SAVE_CODE, default="False") code_disabled = _env_as_bool(DISABLE_CODE, default="False") return save_code and not code_disabled
python
wandb/env.py
398
401
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
884
disable_git
def disable_git(env: Optional[Env] = None) -> bool: if env is None: env = os.environ val = env.get(DISABLE_GIT, default="False") if isinstance(val, str): val = False if val.lower() == "false" else True return val
python
wandb/env.py
404
410
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
885
_datatypes_set_callback
def _datatypes_set_callback(cb): global _glob_datatypes_callback _glob_datatypes_callback = cb
python
wandb/_globals.py
12
14
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
886
_datatypes_callback
def _datatypes_callback(fname): if _glob_datatypes_callback: _glob_datatypes_callback(fname)
python
wandb/_globals.py
17
19
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
887
get_platform_name
def get_platform_name() -> str: if sys.platform.startswith("win"): return PLATFORM_WINDOWS elif sys.platform.startswith("darwin"): return PLATFORM_DARWIN elif sys.platform.startswith("linux"): return PLATFORM_LINUX elif sys.platform.startswith( ( "dragonfly", "freebsd", "netbsd", "openbsd", ) ): return PLATFORM_BSD else: return PLATFORM_UNKNOWN
python
wandb/util.py
113
130
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
888
vendor_setup
def vendor_setup() -> Callable: """Create a function that restores user paths after vendor imports. This enables us to use the vendor directory for packages we don't depend on. Call the returned function after imports are complete. If you don't you may modify the user's path which is never good. Usage: ```python reset_path = vendor_setup() # do any vendor imports... reset_path() ``` """ original_path = [directory for directory in sys.path] def reset_import_path() -> None: sys.path = original_path parent_dir = os.path.abspath(os.path.dirname(__file__)) vendor_dir = os.path.join(parent_dir, "vendor") vendor_packages = ( "gql-0.2.0", "graphql-core-1.1", "watchdog_0_9_0", "promise-2.3.0", ) package_dirs = [os.path.join(vendor_dir, p) for p in vendor_packages] for p in [vendor_dir] + package_dirs: if p not in sys.path: sys.path.insert(1, p) return reset_import_path
python
wandb/util.py
154
187
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
889
reset_import_path
def reset_import_path() -> None: sys.path = original_path
python
wandb/util.py
171
172
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
890
vendor_import
def vendor_import(name: str) -> Any: reset_path = vendor_setup() module = import_module(name) reset_path() return module
python
wandb/util.py
190
194
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
891
import_module_lazy
def import_module_lazy(name: str) -> Any: """Import a module lazily, only when it is used. :param (str) name: Dot-separated module path. E.g., 'scipy.stats'. """ try: return sys.modules[name] except KeyError: module_spec = importlib.util.find_spec(name) if not module_spec: raise ModuleNotFoundError module = importlib.util.module_from_spec(module_spec) sys.modules[name] = module assert module_spec.loader is not None lazy_loader = importlib.util.LazyLoader(module_spec.loader) lazy_loader.exec_module(module) return module
python
wandb/util.py
197
216
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
892
get_module
def get_module( name: str, required: Optional[Union[str, bool]] = None, lazy: bool = True, ) -> Any: """Return module or None. Absolute import is required. :param (str) name: Dot-separated module path. E.g., 'scipy.stats'. :param (str) required: A string to raise a ValueError if missing :param (bool) lazy: If True, return a lazy loader for the module. :return: (module|None) If import succeeds, the module will be returned. """ if name not in _not_importable: try: if not lazy: return import_module(name) else: return import_module_lazy(name) except Exception: _not_importable.add(name) msg = f"Error importing optional module {name}" if required: logger.exception(msg) if required and name in _not_importable: raise wandb.Error(required)
python
wandb/util.py
219
243
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
893
get_optional_module
def get_optional_module(name) -> Optional["importlib.ModuleInterface"]: # type: ignore return get_module(name)
python
wandb/util.py
246
247
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
894
app_url
def app_url(api_url: str) -> str: """Return the frontend app url without a trailing slash.""" # TODO: move me to settings app_url = get_app_url() if app_url is not None: return str(app_url.strip("/")) if "://api.wandb.test" in api_url: # dev mode return api_url.replace("://api.", "://app.").strip("/") elif "://api.wandb." in api_url: # cloud return api_url.replace("://api.", "://").strip("/") elif "://api." in api_url: # onprem cloud return api_url.replace("://api.", "://app.").strip("/") # wandb/local return api_url
python
wandb/util.py
256
272
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
895
get_full_typename
def get_full_typename(o: Any) -> Any: """Determine types based on type names. Avoids needing to to import (and therefore depend on) PyTorch, TensorFlow, etc. """ instance_name = o.__class__.__module__ + "." + o.__class__.__name__ if instance_name in ["builtins.module", "__builtin__.module"]: return o.__name__ else: return instance_name
python
wandb/util.py
275
284
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
896
get_h5_typename
def get_h5_typename(o: Any) -> Any: typename = get_full_typename(o) if is_tf_tensor_typename(typename): return "tensorflow.Tensor" elif is_pytorch_tensor_typename(typename): return "torch.Tensor" else: return o.__class__.__module__.split(".")[0] + "." + o.__class__.__name__
python
wandb/util.py
287
294
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
897
is_uri
def is_uri(string: str) -> bool: parsed_uri = urllib.parse.urlparse(string) return len(parsed_uri.scheme) > 0
python
wandb/util.py
297
299
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
898
local_file_uri_to_path
def local_file_uri_to_path(uri: str) -> str: """Convert URI to local filesystem path. No-op if the uri does not have the expected scheme. """ path = urllib.parse.urlparse(uri).path if uri.startswith("file:") else uri return urllib.request.url2pathname(path)
python
wandb/util.py
302
308
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
899
get_local_path_or_none
def get_local_path_or_none(path_or_uri: str) -> Optional[str]: """Return path if local, None otherwise. Return None if the argument is a local path (not a scheme or file:///). Otherwise return `path_or_uri`. """ parsed_uri = urllib.parse.urlparse(path_or_uri) if ( len(parsed_uri.scheme) == 0 or parsed_uri.scheme == "file" and len(parsed_uri.netloc) == 0 ): return local_file_uri_to_path(path_or_uri) else: return None
python
wandb/util.py
311
325
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
900
make_tarfile
def make_tarfile( output_filename: str, source_dir: str, archive_name: str, custom_filter: Optional[Callable] = None, ) -> None: # Helper for filtering out modification timestamps def _filter_timestamps(tar_info: "tarfile.TarInfo") -> Optional["tarfile.TarInfo"]: tar_info.mtime = 0 return tar_info if custom_filter is None else custom_filter(tar_info) descriptor, unzipped_filename = tempfile.mkstemp() try: with tarfile.open(unzipped_filename, "w") as tar: tar.add(source_dir, arcname=archive_name, filter=_filter_timestamps) # When gzipping the tar, don't include the tar's filename or modification time in the # zipped archive (see https://docs.python.org/3/library/gzip.html#gzip.GzipFile) with gzip.GzipFile( filename="", fileobj=open(output_filename, "wb"), mode="wb", mtime=0 ) as gzipped_tar, open(unzipped_filename, "rb") as tar_file: gzipped_tar.write(tar_file.read()) finally: os.close(descriptor) os.remove(unzipped_filename)
python
wandb/util.py
328
351
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }